mirror of
https://github.com/photonstorm/phaser
synced 2024-11-17 02:08:40 +00:00
commit
f8e895e1bb
402 changed files with 39148 additions and 19377 deletions
|
@ -8,6 +8,11 @@ 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
|
||||
|
|
155
CHANGELOG.md
155
CHANGELOG.md
|
@ -1,11 +1,140 @@
|
|||
# Change Log
|
||||
|
||||
## Version 3.15.0 - Batou - 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.
|
||||
|
||||
### Input Updates and Fixes
|
||||
|
||||
* The Keyboard Plugin will now call `preventDefault` on all non-modified alphanumeric key presses by default, stopping the keyboard event from hitting the browser. Previously, you had to create `Key` objects to enable this. You can control this at runtime by toggling the `KeyboardPlugin.preventDefault` boolean, or the following config setting.
|
||||
* 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 populated with the space key, cursors, 0 - 9 and A - Z. You can also set this in a Scene Config, in which case it will override the Game Config value.
|
||||
* 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.
|
||||
* The Keyboard Plugin has a new 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. Modify this by changing the game config, or altering the array contents at run-time.
|
||||
* The Key object has a new boolean `metaKey` 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.
|
||||
* The Mouse Manager class has been updated to remove some commented out code and refine the `startListeners` method.
|
||||
* 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)
|
||||
* 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 previous and current position. This is updated whenever the Pointer moves, regardless of button states. If you find the velocity is too erratic, consider enabling the `smoothFactor`.
|
||||
* `Pointer.angle` is a new property that contains the angle of the Pointer, in radians, based on the previous and current position. This is updated whenever the Pointer moves, regardless of button states. If you find the angle is too erratic, consider enabling the `smoothFactor`.
|
||||
|
||||
### New Features
|
||||
|
||||
* 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)
|
||||
|
||||
### Updates
|
||||
|
||||
* The `backgroundColor` property of the Game Config is now used to set the CSS backgroundColor property of the game Canvas element. This avoids a `fillRect` call in Canvas mode and allows for 'punch through' effects to be created. If `transparent` is true, the CSS property is not set and no background color is drawn in either WebGL or Canvas, allowing the canvas to be fully transparent.
|
||||
* 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.
|
||||
|
||||
### 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)
|
||||
* 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.
|
||||
|
||||
### 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
|
||||
|
||||
### 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:
|
||||
|
||||
16patsle - @icbat - @gurungrahul2 - @samme - @telinc1 - anandu pavanan - blackhawx - candelibas - Diego Romero - Elliott Wallace - eric - Georges Gabereau - Haobo Zhang - henriacle - madclaws - marc136 - Mihail Ilinov - naum303 - NicolasRoehm - rejacobson - Robert Kowalski - rootasjey - scottwestover - stetso - therealsamf - Tigran - willblackmore - zenwaichi
|
||||
|
||||
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.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
|
||||
|
||||
|
@ -14,6 +143,12 @@
|
|||
* 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
|
||||
|
||||
|
@ -21,22 +156,8 @@
|
|||
* 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)
|
||||
|
||||
### 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:
|
||||
|
||||
|
||||
|
||||
### 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:
|
||||
|
||||
---
|
||||
|
||||
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).
|
||||
|
||||
|
||||
* 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
|
||||
|
||||
|
|
147
README.md
147
README.md
|
@ -24,6 +24,12 @@ Grab the source and join the fun!
|
|||
|
||||
<div align="center"><img src="https://phaser.io/images/github/news.jpg"></div>
|
||||
|
||||
> 16th October 2018
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
> 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.
|
||||
|
@ -102,13 +108,13 @@ npm install phaser
|
|||
[Phaser is on jsDelivr](https://www.jsdelivr.com/projects/phaser) which is a "super-fast CDN for developers". Include the following in your html:
|
||||
|
||||
```html
|
||||
<script src="//cdn.jsdelivr.net/npm/phaser@3.14/dist/phaser.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/npm/phaser@3.15/dist/phaser.js"></script>
|
||||
```
|
||||
|
||||
or the minified version:
|
||||
|
||||
```html
|
||||
<script src="//cdn.jsdelivr.net/npm/phaser@3.14/dist/phaser.min.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/npm/phaser@3.15/dist/phaser.min.js"></script>
|
||||
```
|
||||
|
||||
### API Documentation
|
||||
|
@ -151,7 +157,7 @@ Also, please subscribe to the [Phaser World](https://phaser.io/community/newslet
|
|||
|
||||
### Facebook Instant Games
|
||||
|
||||
Phaser 3.13 introduces the new [Facebook Instant Games](https://developers.facebook.com/docs/games/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.
|
||||
Phaser 3.13 introduced the new [Facebook Instant Games](https://developers.facebook.com/docs/games/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:
|
||||
|
||||
|
@ -174,13 +180,13 @@ The plugin offers the following features:
|
|||
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
|
||||
<script src="//cdn.jsdelivr.net/npm/phaser@3.14/dist/phaser-facebook-instant-games.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/npm/phaser@3.15/dist/phaser-facebook-instant-games.js"></script>
|
||||
```
|
||||
|
||||
or the minified version:
|
||||
|
||||
```html
|
||||
<script src="//cdn.jsdelivr.net/npm/phaser@3.14/dist/phaser-facebook-instant-games.min.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/npm/phaser@3.15/dist/phaser-facebook-instant-games.min.js"></script>
|
||||
```
|
||||
|
||||
The build files are in the git repository in the `dist` folder, and you can also include the plugin in custom builds.
|
||||
|
@ -189,30 +195,6 @@ The build files are in the git repository in the `dist` folder, and you can also
|
|||
|
||||
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.
|
||||
|
||||
### Facebook Instant Games
|
||||
|
||||
Phaser 3.13 introduced 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.
|
||||
|
||||
### Create Your First Phaser 3 Example
|
||||
|
||||
Create an `index.html` page locally and paste the following code into it:
|
||||
|
@ -323,7 +305,7 @@ Read our [comprehensive guide](https://phaser.io/phaser3/devlog/127) on creating
|
|||
|
||||
### 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`.
|
||||
|
||||
|
@ -332,95 +314,42 @@ You can then run `webpack` to create a development build in the `build` folder w
|
|||
|
||||
# Change Log
|
||||
|
||||
## Version 3.14.0 - Tachikoma - 1st October 2018
|
||||
## Version 3.15.1 - Batou - 16th 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.
|
||||
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
|
||||
|
||||
* `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.
|
||||
* 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 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.
|
||||
* `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
|
||||
|
||||
* 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).
|
||||
* 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.
|
||||
|
||||
|
|
6524
dist/phaser-arcade-physics.js
vendored
6524
dist/phaser-arcade-physics.js
vendored
File diff suppressed because it is too large
Load diff
2
dist/phaser-arcade-physics.min.js
vendored
2
dist/phaser-arcade-physics.min.js
vendored
File diff suppressed because one or more lines are too long
6206
dist/phaser-facebook-instant-games.js
vendored
6206
dist/phaser-facebook-instant-games.js
vendored
File diff suppressed because it is too large
Load diff
2
dist/phaser-facebook-instant-games.min.js
vendored
2
dist/phaser-facebook-instant-games.min.js
vendored
File diff suppressed because one or more lines are too long
6956
dist/phaser.js
vendored
6956
dist/phaser.js
vendored
File diff suppressed because it is too large
Load diff
2
dist/phaser.min.js
vendored
2
dist/phaser.min.js
vendored
File diff suppressed because one or more lines are too long
4070
package-lock.json
generated
4070
package-lock.json
generated
File diff suppressed because it is too large
Load diff
21
package.json
21
package.json
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "phaser",
|
||||
"version": "3.15.0-beta1",
|
||||
"release": "Batou",
|
||||
"version": "3.16.0",
|
||||
"release": "Ishikawa",
|
||||
"description": "A fast, free and fun HTML5 Game Framework for Desktop and Mobile web browsers.",
|
||||
"author": "Richard Davey <rich@photonstorm.com> (http://www.photonstorm.com)",
|
||||
"logo": "https://raw.github.com/photonstorm/phaser/master/phaser-logo-small.png",
|
||||
|
@ -25,6 +25,13 @@
|
|||
"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\"",
|
||||
|
@ -49,13 +56,15 @@
|
|||
"eslint-plugin-es5": "^1.3.1",
|
||||
"fs-extra": "^6.0.0",
|
||||
"node-sloc": "^0.1.11",
|
||||
"uglifyjs-webpack-plugin": "^1.2.7",
|
||||
"uglifyjs-webpack-plugin": "^1.3.0",
|
||||
"vivid-cli": "^1.1.2",
|
||||
"webpack": "^4.16.0",
|
||||
"webpack-cli": "^2.1.5",
|
||||
"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"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -687,7 +687,7 @@ var FacebookInstantGamesPlugin = new Class({
|
|||
|
||||
scene.load.image(key, this.playerPhotoURL);
|
||||
|
||||
scene.load.once('filecomplete_image_' + key, function ()
|
||||
scene.load.once('filecomplete-image-' + key, function ()
|
||||
{
|
||||
this.emit('photocomplete', key);
|
||||
|
||||
|
|
|
@ -139,13 +139,15 @@ var Leaderboard = new Class({
|
|||
*
|
||||
* 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.
|
||||
* 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} [data] - Metadata to associate with the stored score. Must be less than 2KB in size.
|
||||
* @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.
|
||||
*/
|
||||
|
@ -153,11 +155,27 @@ var Leaderboard = new Class({
|
|||
{
|
||||
if (data === undefined) { data = ''; }
|
||||
|
||||
if (typeof data === 'object')
|
||||
{
|
||||
data = JSON.stringify(data);
|
||||
}
|
||||
|
||||
var _this = this;
|
||||
|
||||
this.ref.setScoreAsync(score, data).then(function (entry)
|
||||
{
|
||||
_this.emit('setscore', entry.getScore(), entry.getExtraData(), _this.name);
|
||||
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)
|
||||
{
|
||||
|
@ -173,6 +191,8 @@ var Leaderboard = new Class({
|
|||
* 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
|
||||
|
@ -185,11 +205,18 @@ var Leaderboard = new Class({
|
|||
|
||||
this.ref.getPlayerEntryAsync().then(function (entry)
|
||||
{
|
||||
var score = LeaderboardScore(entry);
|
||||
if (entry)
|
||||
{
|
||||
var score = LeaderboardScore(entry);
|
||||
|
||||
_this.playerScore = score;
|
||||
|
||||
_this.emit('getplayerscore', score, _this.name);
|
||||
_this.playerScore = score;
|
||||
|
||||
_this.emit('getplayerscore', score, _this.name);
|
||||
}
|
||||
else
|
||||
{
|
||||
_this.emit('getplayerscore', null, _this.name);
|
||||
}
|
||||
|
||||
}).catch(function (e)
|
||||
{
|
||||
|
@ -204,7 +231,7 @@ var Leaderboard = new Class({
|
|||
*
|
||||
* 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.
|
||||
* 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
|
||||
|
@ -237,6 +264,47 @@ var Leaderboard = new Class({
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
13
plugins/spine/copy-to-examples.js
Normal file
13
plugins/spine/copy-to-examples.js
Normal file
|
@ -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');
|
||||
}
|
19720
plugins/spine/dist/SpineWebGLPlugin.js
vendored
Normal file
19720
plugins/spine/dist/SpineWebGLPlugin.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
plugins/spine/dist/SpineWebGLPlugin.js.map
vendored
Normal file
1
plugins/spine/dist/SpineWebGLPlugin.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
1263
plugins/spine/spine-canvas.d.ts
vendored
1263
plugins/spine/spine-canvas.d.ts
vendored
File diff suppressed because it is too large
Load diff
1667
plugins/spine/spine-webgl.d.ts
vendored
1667
plugins/spine/spine-webgl.d.ts
vendored
File diff suppressed because it is too large
Load diff
190
plugins/spine/src/BaseSpinePlugin.js
Normal file
190
plugins/spine/src/BaseSpinePlugin.js
Normal file
|
@ -0,0 +1,190 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var 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;
|
63
plugins/spine/src/SpineCanvasPlugin.js
Normal file
63
plugins/spine/src/SpineCanvasPlugin.js
Normal file
|
@ -0,0 +1,63 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var 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;
|
325
plugins/spine/src/SpineFile.js
Normal file
325
plugins/spine/src/SpineFile.js
Normal file
|
@ -0,0 +1,325 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var 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 `<key>.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 `<key>.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 `<key>.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 `<key>.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;
|
111
plugins/spine/src/SpinePlugin.js
Normal file
111
plugins/spine/src/SpinePlugin.js
Normal file
|
@ -0,0 +1,111 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var 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;
|
90
plugins/spine/src/SpineWebGLPlugin.js
Normal file
90
plugins/spine/src/SpineWebGLPlugin.js
Normal file
|
@ -0,0 +1,90 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var 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;
|
298
plugins/spine/src/gameobject/SpineGameObject.js
Normal file
298
plugins/spine/src/gameobject/SpineGameObject.js
Normal file
|
@ -0,0 +1,298 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var 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;
|
|
@ -0,0 +1,57 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var 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;
|
33
plugins/spine/src/gameobject/SpineGameObjectFactory.js
Normal file
33
plugins/spine/src/gameobject/SpineGameObjectFactory.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var 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;
|
||||
});
|
25
plugins/spine/src/gameobject/SpineGameObjectRender.js
Normal file
25
plugins/spine/src/gameobject/SpineGameObjectRender.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var 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
|
||||
|
||||
};
|
121
plugins/spine/src/gameobject/SpineGameObjectWebGLRenderer.js
Normal file
121
plugins/spine/src/gameobject/SpineGameObjectWebGLRenderer.js
Normal file
|
@ -0,0 +1,121 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var 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;
|
27
plugins/spine/src/runtimes/LICENSE
Normal file
27
plugins/spine/src/runtimes/LICENSE
Normal file
|
@ -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.
|
76
plugins/spine/webpack.auto.config.js
Normal file
76
plugins/spine/webpack.auto.config.js
Normal file
|
@ -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'
|
||||
};
|
94
plugins/spine/webpack.auto.dist.config.js
Normal file
94
plugins/spine/webpack.auto.dist.config.js
Normal file
|
@ -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);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
76
plugins/spine/webpack.canvas.config.js
Normal file
76
plugins/spine/webpack.canvas.config.js
Normal file
|
@ -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'
|
||||
};
|
94
plugins/spine/webpack.canvas.dist.config.js
Normal file
94
plugins/spine/webpack.canvas.dist.config.js
Normal file
|
@ -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);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
76
plugins/spine/webpack.webgl.config.js
Normal file
76
plugins/spine/webpack.webgl.config.js
Normal file
|
@ -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'
|
||||
};
|
94
plugins/spine/webpack.webgl.dist.config.js
Normal file
94
plugins/spine/webpack.webgl.dist.config.js
Normal file
|
@ -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);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
|
@ -64,7 +64,7 @@ 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
|
||||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
|
@ -803,7 +803,7 @@ var Animation = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Sets the texture frame the animation uses for rendering.
|
||||
*
|
||||
* @method Phaser.Animations.Animation#setFrame
|
||||
* @since 3.0.0
|
||||
|
@ -824,7 +824,7 @@ var Animation = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Converts the animation data to JSON.
|
||||
*
|
||||
* @method Phaser.Animations.Animation#toJSON
|
||||
* @since 3.0.0
|
||||
|
|
|
@ -25,7 +25,7 @@ var Class = require('../utils/Class');
|
|||
* AnimationFrames are generated automatically by the Animation class.
|
||||
*
|
||||
* @class AnimationFrame
|
||||
* @memberOf Phaser.Animations
|
||||
* @memberof Phaser.Animations
|
||||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
|
@ -82,7 +82,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 +93,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 +104,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 +115,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 +138,7 @@ var AnimationFrame = new Class({
|
|||
* @name Phaser.Animations.AnimationFrame#progress
|
||||
* @type {number}
|
||||
* @default 0
|
||||
* @readOnly
|
||||
* @readonly
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.progress = 0;
|
||||
|
|
|
@ -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,7 +30,7 @@ var Pad = require('../utils/string/Pad');
|
|||
*
|
||||
* @class AnimationManager
|
||||
* @extends Phaser.Events.EventEmitter
|
||||
* @memberOf Phaser.Animations
|
||||
* @memberof Phaser.Animations
|
||||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
|
@ -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.<string, Phaser.Animations.Animation>}
|
||||
|
@ -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,13 +155,13 @@ var AnimationManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Creates a new Animation and adds it to the Animation Manager.
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
|
@ -181,12 +185,12 @@ var AnimationManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [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 {(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,19 +236,17 @@ 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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}.
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Animations.AnimationManager#generateFrameNames
|
||||
* @since 3.0.0
|
||||
|
|
|
@ -11,6 +11,8 @@ var GetFastValue = require('../utils/object/GetFastValue');
|
|||
var GetValue = require('../utils/object/GetValue');
|
||||
var IsPlainObject = require('../utils/object/IsPlainObject');
|
||||
var MATH = require('../math/const');
|
||||
var NumberArray = require('../utils/array/NumberArray');
|
||||
var RND = require('../math/random-data-generator/RandomDataGenerator');
|
||||
var NOOP = require('../utils/NOOP');
|
||||
var DefaultPlugins = require('../plugins/DefaultPlugins');
|
||||
var ValueToColor = require('../display/color/ValueToColor');
|
||||
|
@ -27,6 +29,20 @@ var ValueToColor = require('../display/color/ValueToColor');
|
|||
* @param {Phaser.Game} game - The game.
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} InputConfig
|
||||
*
|
||||
|
@ -35,19 +51,21 @@ var ValueToColor = require('../display/color/ValueToColor');
|
|||
* @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.
|
||||
* @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 {(boolean|integer[])} [capture] - `preventDefault` will be called on every non-modified key which has a key code in this array. By default, it's set to all the space key, cursors and all alphanumeric keys. Or, set to 'false' to disable.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -74,11 +92,11 @@ var ValueToColor = require('../display/color/ValueToColor');
|
|||
/**
|
||||
* @typedef {object} FPSConfig
|
||||
*
|
||||
* @property {integer} [min=10] - The minimum acceptable rendering rate, in frames per second.
|
||||
* @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] - [description]
|
||||
* @property {integer} [panicMax=120] - The amount of frames the time step counts before we trust the delta values again.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -91,7 +109,6 @@ var ValueToColor = require('../display/color/ValueToColor');
|
|||
* @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.
|
||||
|
@ -123,14 +140,14 @@ var ValueToColor = require('../display/color/ValueToColor');
|
|||
/**
|
||||
* @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 {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 the XHR request.
|
||||
* @property {string} [password] - Optional password for the XHR request.
|
||||
* @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.
|
||||
*/
|
||||
|
||||
|
@ -221,7 +238,7 @@ var ValueToColor = require('../display/color/ValueToColor');
|
|||
* The active game configuration settings, parsed from a {@link GameConfig} object.
|
||||
*
|
||||
* @class Config
|
||||
* @memberOf Phaser.Boot
|
||||
* @memberof Phaser.Boot
|
||||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
|
@ -248,35 +265,60 @@ 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 {?*} 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 {?*} Phaser.Boot.Config#scaleMode - [description]
|
||||
* @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);
|
||||
|
@ -289,8 +331,11 @@ var Config = new Class({
|
|||
this.resolution = GetValue(scaleConfig, 'resolution', this.resolution);
|
||||
this.parent = GetValue(scaleConfig, 'parent', this.parent);
|
||||
this.scaleMode = GetValue(scaleConfig, 'mode', this.scaleMode);
|
||||
|
||||
// TODO: Add in min / max sizes
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -309,20 +354,27 @@ 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 = new RND();
|
||||
|
||||
MATH.RND.init(this.seed);
|
||||
|
||||
/**
|
||||
|
@ -341,108 +393,130 @@ var Config = new Class({
|
|||
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 - [description]
|
||||
* @const {?boolean} Phaser.Boot.Config#domCreateContainer - EXPERIMENTAL: Do not currently use.
|
||||
*/
|
||||
this.domCreateContainer = GetValue(config, 'dom.createContainer', false);
|
||||
|
||||
/**
|
||||
* @const {?boolean} Phaser.Boot.Config#domBehindCanvas - [description]
|
||||
* @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 {(boolean|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's set to all alphanumeric keys. Or, set to 'false' to disable.
|
||||
*/
|
||||
var defaultCaptures = [ 32, 38, 39, 40, 42 ];
|
||||
|
||||
defaultCaptures = defaultCaptures.concat(NumberArray(48, 57));
|
||||
defaultCaptures = defaultCaptures.concat(NumberArray(65, 90));
|
||||
|
||||
var keyboardCapture = GetValue(config, 'input.keyboard.capture', defaultCaptures);
|
||||
|
||||
if (!Array.isArray(keyboardCapture))
|
||||
{
|
||||
keyboardCapture = [];
|
||||
}
|
||||
|
||||
this.inputKeyboardCapture = keyboardCapture;
|
||||
|
||||
/**
|
||||
* @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', 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 - Set to `true` to disable context menu. Default value is `false`.
|
||||
* @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 {SoundConfig} 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);
|
||||
|
||||
|
@ -451,16 +525,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);
|
||||
|
||||
|
@ -475,12 +541,12 @@ var Config = new Class({
|
|||
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);
|
||||
|
||||
|
@ -496,32 +562,27 @@ 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#clearBeforeRender - [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');
|
||||
|
||||
|
@ -538,7 +599,7 @@ var Config = new Class({
|
|||
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);
|
||||
|
||||
|
@ -547,45 +608,33 @@ 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', '');
|
||||
|
||||
|
@ -595,37 +644,35 @@ var Config = new Class({
|
|||
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.
|
||||
|
@ -645,12 +692,12 @@ var Config = new Class({
|
|||
*/
|
||||
|
||||
/**
|
||||
* @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 = [];
|
||||
|
||||
|
@ -689,12 +736,12 @@ 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==');
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ var CreateRenderer = function (game)
|
|||
// 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.customEnvironment || config.canvas) && config.renderType !== CONST.HEADLESS)
|
||||
{
|
||||
if (config.renderType === CONST.CANVAS || (config.renderType !== CONST.CANVAS && !Features.webGL))
|
||||
{
|
||||
|
@ -47,6 +47,11 @@ var CreateRenderer = function (game)
|
|||
}
|
||||
}
|
||||
|
||||
if (config.customEnvironment && config.renderType === CONST.AUTO)
|
||||
{
|
||||
throw new Error('Must set renderType in custom environment');
|
||||
}
|
||||
|
||||
// Pixel Art mode?
|
||||
if (!config.antialias)
|
||||
{
|
||||
|
@ -57,10 +62,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.resolution, config.height * config.resolution, 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?
|
||||
|
@ -69,16 +77,18 @@ var CreateRenderer = function (game)
|
|||
game.canvas.style = config.canvasStyle;
|
||||
}
|
||||
|
||||
// Background color
|
||||
if (!config.transparent)
|
||||
{
|
||||
game.canvas.style.backgroundColor = config.backgroundColor.rgba;
|
||||
}
|
||||
|
||||
// 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
|
||||
|
@ -97,9 +107,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
|
||||
{
|
||||
|
@ -116,9 +123,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)
|
||||
|
|
|
@ -47,7 +47,7 @@ if (typeof PLUGIN_FBINSTANT)
|
|||
* made available to you via the Phaser.Scene Systems class instead.
|
||||
*
|
||||
* @class Game
|
||||
* @memberOf Phaser
|
||||
* @memberof Phaser
|
||||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
|
@ -66,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);
|
||||
|
@ -126,7 +126,7 @@ var Game = new Class({
|
|||
*
|
||||
* @name Phaser.Game#isBooted
|
||||
* @type {boolean}
|
||||
* @readOnly
|
||||
* @readonly
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.isBooted = false;
|
||||
|
@ -136,7 +136,7 @@ var Game = new Class({
|
|||
*
|
||||
* @name Phaser.Game#isRunning
|
||||
* @type {boolean}
|
||||
* @readOnly
|
||||
* @readonly
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.isRunning = false;
|
||||
|
@ -231,11 +231,11 @@ var Game = new Class({
|
|||
*
|
||||
* The Scale Manager is a global system responsible for handling game scaling events.
|
||||
*
|
||||
* @name Phaser.Game#scaleManager
|
||||
* @name Phaser.Game#scale
|
||||
* @type {Phaser.Boot.ScaleManager}
|
||||
* @since 3.15.0
|
||||
*/
|
||||
this.scaleManager = new ScaleManager(this, this.config);
|
||||
this.scale = new ScaleManager(this, this.config);
|
||||
|
||||
/**
|
||||
* An instance of the base Sound Manager.
|
||||
|
@ -324,7 +324,7 @@ var Game = new Class({
|
|||
*
|
||||
* @name Phaser.Game#hasFocus
|
||||
* @type {boolean}
|
||||
* @readOnly
|
||||
* @readonly
|
||||
* @since 3.9.0
|
||||
*/
|
||||
this.hasFocus = false;
|
||||
|
@ -335,7 +335,7 @@ var Game = new Class({
|
|||
*
|
||||
* @name Phaser.Game#isOver
|
||||
* @type {boolean}
|
||||
* @readOnly
|
||||
* @readonly
|
||||
* @since 3.10.0
|
||||
*/
|
||||
this.isOver = true;
|
||||
|
@ -367,7 +367,7 @@ var Game = new Class({
|
|||
{
|
||||
if (!PluginCache.hasCore('EventEmitter'))
|
||||
{
|
||||
console.warn('Core Phaser Plugins missing. Cannot start.');
|
||||
console.warn('Aborting. Core Plugins missing.');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -375,6 +375,8 @@ var Game = new Class({
|
|||
|
||||
this.config.preBoot(this);
|
||||
|
||||
this.scale.preBoot();
|
||||
|
||||
CreateRenderer(this);
|
||||
|
||||
if (typeof EXPERIMENTAL)
|
||||
|
@ -818,4 +820,8 @@ var Game = new Class({
|
|||
|
||||
});
|
||||
|
||||
/**
|
||||
* "Computers are good at following instructions, but not at reading your mind." - Donald Knuth
|
||||
*/
|
||||
|
||||
module.exports = Game;
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
2
src/cache/BaseCache.js
vendored
2
src/cache/BaseCache.js
vendored
|
@ -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
|
||||
*/
|
||||
|
|
2
src/cache/CacheManager.js
vendored
2
src/cache/CacheManager.js
vendored
|
@ -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
|
||||
*
|
||||
|
|
|
@ -67,7 +67,7 @@ var Vector2 = require('../../math/Vector2');
|
|||
* to when they were added to the Camera class.
|
||||
*
|
||||
* @class BaseCamera
|
||||
* @memberOf Phaser.Cameras.Scene2D
|
||||
* @memberof Phaser.Cameras.Scene2D
|
||||
* @constructor
|
||||
* @since 3.12.0
|
||||
*
|
||||
|
@ -123,7 +123,7 @@ var BaseCamera = new Class({
|
|||
*
|
||||
* @name Phaser.Cameras.Scene2D.BaseCamera#config
|
||||
* @type {object}
|
||||
* @readOnly
|
||||
* @readonly
|
||||
* @since 3.12.0
|
||||
*/
|
||||
this.config;
|
||||
|
@ -134,7 +134,7 @@ var BaseCamera = new Class({
|
|||
*
|
||||
* @name Phaser.Cameras.Scene2D.BaseCamera#id
|
||||
* @type {integer}
|
||||
* @readOnly
|
||||
* @readonly
|
||||
* @since 3.11.0
|
||||
*/
|
||||
this.id = 0;
|
||||
|
@ -154,7 +154,7 @@ var BaseCamera = new Class({
|
|||
*
|
||||
* @name Phaser.Cameras.Scene2D.BaseCamera#resolution
|
||||
* @type {number}
|
||||
* @readOnly
|
||||
* @readonly
|
||||
* @since 3.12.0
|
||||
*/
|
||||
this.resolution = 1;
|
||||
|
@ -201,7 +201,7 @@ var BaseCamera = new Class({
|
|||
*
|
||||
* @name Phaser.Cameras.Scene2D.BaseCamera#worldView
|
||||
* @type {Phaser.Geom.Rectangle}
|
||||
* @readOnly
|
||||
* @readonly
|
||||
* @since 3.11.0
|
||||
*/
|
||||
this.worldView = new Rectangle();
|
||||
|
@ -464,7 +464,7 @@ var BaseCamera = new Class({
|
|||
*
|
||||
* @name Phaser.Cameras.Scene2D.BaseCamera#midPoint
|
||||
* @type {Phaser.Math.Vector2}
|
||||
* @readOnly
|
||||
* @readonly
|
||||
* @since 3.11.0
|
||||
*/
|
||||
this.midPoint = new Vector2(width / 2, height / 2);
|
||||
|
@ -727,11 +727,12 @@ var BaseCamera = new Class({
|
|||
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;
|
||||
var cullTop = this.y;
|
||||
var cullBottom = cullTop + cameraH;
|
||||
var cullLeft = this.x;
|
||||
var cullRight = cullLeft + cameraW;
|
||||
|
||||
if (tx > -objectW && ty > -objectH && tx < cullW && ty < cullH &&
|
||||
tw > -objectW && th > -objectH && tw < cullW && th < cullH)
|
||||
if ((tw > cullLeft && tx < cullRight) && (th > cullTop && ty < cullBottom))
|
||||
{
|
||||
culledObjects.push(object);
|
||||
}
|
||||
|
@ -1700,11 +1701,11 @@ var BaseCamera = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* The x position of the center of the Camera's viewport, relative to the top-left of the game canvas.
|
||||
* 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
|
||||
* @readonly
|
||||
* @since 3.10.0
|
||||
*/
|
||||
centerX: {
|
||||
|
@ -1717,11 +1718,11 @@ var BaseCamera = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* The y position of the center of the Camera's viewport, relative to the top-left of the game canvas.
|
||||
* 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
|
||||
* @readonly
|
||||
* @since 3.10.0
|
||||
*/
|
||||
centerY: {
|
||||
|
@ -1744,7 +1745,7 @@ var BaseCamera = new Class({
|
|||
*
|
||||
* @name Phaser.Cameras.Scene2D.BaseCamera#displayWidth
|
||||
* @type {number}
|
||||
* @readOnly
|
||||
* @readonly
|
||||
* @since 3.11.0
|
||||
*/
|
||||
displayWidth: {
|
||||
|
@ -1767,7 +1768,7 @@ var BaseCamera = new Class({
|
|||
*
|
||||
* @name Phaser.Cameras.Scene2D.BaseCamera#displayHeight
|
||||
* @type {number}
|
||||
* @readOnly
|
||||
* @readonly
|
||||
* @since 3.11.0
|
||||
*/
|
||||
displayHeight: {
|
||||
|
|
|
@ -39,7 +39,7 @@ var Vector2 = require('../../math/Vector2');
|
|||
* A Camera also has built-in special effects including Fade, Flash and Camera Shake.
|
||||
*
|
||||
* @class Camera
|
||||
* @memberOf Phaser.Cameras.Scene2D
|
||||
* @memberof Phaser.Cameras.Scene2D
|
||||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
@ -222,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.
|
||||
|
@ -271,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
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
@ -30,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({
|
||||
|
||||
|
@ -159,7 +167,7 @@ var FixedKeyControl = new Class({
|
|||
}
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Internal property to track the current zoom level.
|
||||
*
|
||||
* @name Phaser.Cameras.Controls.FixedKeyControl#_zoom
|
||||
* @type {number}
|
||||
|
@ -227,7 +235,9 @@ 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
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
26
src/const.js
26
src/const.js
|
@ -16,23 +16,21 @@ var CONST = {
|
|||
* Phaser Release Version
|
||||
*
|
||||
* @name Phaser.VERSION
|
||||
* @readOnly
|
||||
* @readonly
|
||||
* @type {string}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
VERSION: '3.15.0 Beta 1',
|
||||
VERSION: '3.16.0 Beta 2',
|
||||
|
||||
BlendModes: require('./renderer/BlendModes'),
|
||||
|
||||
ScaleModes: require('./renderer/ScaleModes'),
|
||||
|
||||
ScaleManager: require('./dom/const'),
|
||||
|
||||
/**
|
||||
* AUTO Detect Renderer.
|
||||
*
|
||||
* @name Phaser.AUTO
|
||||
* @readOnly
|
||||
* @readonly
|
||||
* @type {integer}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
|
@ -42,7 +40,7 @@ var CONST = {
|
|||
* Canvas Renderer.
|
||||
*
|
||||
* @name Phaser.CANVAS
|
||||
* @readOnly
|
||||
* @readonly
|
||||
* @type {integer}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
|
@ -52,7 +50,7 @@ var CONST = {
|
|||
* WebGL Renderer.
|
||||
*
|
||||
* @name Phaser.WEBGL
|
||||
* @readOnly
|
||||
* @readonly
|
||||
* @type {integer}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
|
@ -62,7 +60,7 @@ var CONST = {
|
|||
* Headless Renderer.
|
||||
*
|
||||
* @name Phaser.HEADLESS
|
||||
* @readOnly
|
||||
* @readonly
|
||||
* @type {integer}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
|
@ -73,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
|
||||
*/
|
||||
|
@ -83,7 +81,7 @@ var CONST = {
|
|||
* Direction constant.
|
||||
*
|
||||
* @name Phaser.NONE
|
||||
* @readOnly
|
||||
* @readonly
|
||||
* @type {integer}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
|
@ -93,7 +91,7 @@ var CONST = {
|
|||
* Direction constant.
|
||||
*
|
||||
* @name Phaser.UP
|
||||
* @readOnly
|
||||
* @readonly
|
||||
* @type {integer}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
|
@ -103,7 +101,7 @@ var CONST = {
|
|||
* Direction constant.
|
||||
*
|
||||
* @name Phaser.DOWN
|
||||
* @readOnly
|
||||
* @readonly
|
||||
* @type {integer}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
|
@ -113,7 +111,7 @@ var CONST = {
|
|||
* Direction constant.
|
||||
*
|
||||
* @name Phaser.LEFT
|
||||
* @readOnly
|
||||
* @readonly
|
||||
* @type {integer}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
|
@ -123,7 +121,7 @@ var CONST = {
|
|||
* Direction constant.
|
||||
*
|
||||
* @name Phaser.RIGHT
|
||||
* @readOnly
|
||||
* @readonly
|
||||
* @type {integer}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
|
|
|
@ -17,7 +17,7 @@ var Vector2 = require('../math/Vector2');
|
|||
*
|
||||
* @class CubicBezier
|
||||
* @extends Phaser.Curves.Curve
|
||||
* @memberOf Phaser.Curves
|
||||
* @memberof Phaser.Curves
|
||||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -48,7 +48,7 @@ var Vector2 = require('../math/Vector2');
|
|||
*
|
||||
* @class Ellipse
|
||||
* @extends Phaser.Curves.Curve
|
||||
* @memberOf Phaser.Curves
|
||||
* @memberof Phaser.Curves
|
||||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -12,7 +12,7 @@ var Vector2 = require('../../math/Vector2');
|
|||
* [description]
|
||||
*
|
||||
* @class MoveTo
|
||||
* @memberOf Phaser.Curves
|
||||
* @memberof Phaser.Curves
|
||||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
|
|
|
@ -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,7 +576,9 @@ 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
|
||||
|
@ -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]
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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))
|
||||
{
|
||||
|
@ -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;
|
||||
|
|
|
@ -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 ()
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -15,7 +15,7 @@ var RGBToHSV = require('./RGBToHSV');
|
|||
* 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
|
||||
*
|
||||
|
@ -522,7 +522,7 @@ var Color = new Class({
|
|||
*
|
||||
* @name Phaser.Display.Color#color
|
||||
* @type {number}
|
||||
* @readOnly
|
||||
* @readonly
|
||||
* @since 3.0.0
|
||||
*/
|
||||
color: {
|
||||
|
@ -539,7 +539,7 @@ var Color = new Class({
|
|||
*
|
||||
* @name Phaser.Display.Color#color32
|
||||
* @type {number}
|
||||
* @readOnly
|
||||
* @readonly
|
||||
* @since 3.0.0
|
||||
*/
|
||||
color32: {
|
||||
|
@ -556,7 +556,7 @@ var Color = new Class({
|
|||
*
|
||||
* @name Phaser.Display.Color#rgba
|
||||
* @type {string}
|
||||
* @readOnly
|
||||
* @readonly
|
||||
* @since 3.0.0
|
||||
*/
|
||||
rgba: {
|
||||
|
|
|
@ -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({
|
||||
|
@ -45,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}
|
||||
|
@ -55,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}
|
||||
|
@ -65,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}
|
||||
|
@ -75,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}
|
||||
|
@ -84,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}
|
||||
|
@ -93,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}
|
||||
|
@ -134,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
|
||||
|
@ -147,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)
|
||||
|
@ -162,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)
|
||||
{
|
||||
|
@ -175,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 ()
|
||||
|
@ -190,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 ()
|
||||
{
|
||||
|
|
|
@ -15,7 +15,7 @@ var Class = require('../../utils/Class');
|
|||
* 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
|
||||
*
|
||||
|
|
|
@ -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;
|
||||
|
|
26
src/dom/Calibrate.js
Normal file
26
src/dom/Calibrate.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var 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;
|
12
src/dom/ClientHeight.js
Normal file
12
src/dom/ClientHeight.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var ClientHeight = function ()
|
||||
{
|
||||
return Math.max(window.innerHeight, document.documentElement.clientHeight);
|
||||
};
|
||||
|
||||
module.exports = ClientHeight;
|
12
src/dom/ClientWidth.js
Normal file
12
src/dom/ClientWidth.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var ClientWidth = function ()
|
||||
{
|
||||
return Math.max(window.innerWidth, document.documentElement.clientWidth);
|
||||
};
|
||||
|
||||
module.exports = ClientWidth;
|
41
src/dom/DocumentBounds.js
Normal file
41
src/dom/DocumentBounds.js
Normal file
|
@ -0,0 +1,41 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var 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();
|
30
src/dom/GetAspectRatio.js
Normal file
30
src/dom/GetAspectRatio.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var 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;
|
25
src/dom/GetBounds.js
Normal file
25
src/dom/GetBounds.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var 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;
|
28
src/dom/GetOffset.js
Normal file
28
src/dom/GetOffset.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var 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;
|
56
src/dom/GetScreenOrientation.js
Normal file
56
src/dom/GetScreenOrientation.js
Normal file
|
@ -0,0 +1,56 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var 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;
|
17
src/dom/InLayoutViewport.js
Normal file
17
src/dom/InLayoutViewport.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
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;
|
56
src/dom/LayoutBounds.js
Normal file
56
src/dom/LayoutBounds.js
Normal file
|
@ -0,0 +1,56 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var 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();
|
|
@ -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
|
||||
*/
|
||||
|
|
File diff suppressed because it is too large
Load diff
62
src/dom/VisualBounds.js
Normal file
62
src/dom/VisualBounds.js
Normal file
|
@ -0,0 +1,62 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var 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();
|
1447
src/dom/_ScaleManager.js
Normal file
1447
src/dom/_ScaleManager.js
Normal file
File diff suppressed because it is too large
Load diff
|
@ -7,68 +7,45 @@
|
|||
/**
|
||||
* Phaser ScaleManager Modes.
|
||||
*
|
||||
* @name Phaser.ScaleManager
|
||||
* @name Phaser.DOM.ScaleModes
|
||||
* @enum {integer}
|
||||
* @memberOf Phaser
|
||||
* @readOnly
|
||||
* @memberof Phaser
|
||||
* @readonly
|
||||
* @since 3.15.0
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
|
||||
/**
|
||||
* A scale mode that stretches content to fill all available space - see {@link Phaser.ScaleManager#scaleMode scaleMode}.
|
||||
*
|
||||
* @name Phaser.ScaleManager.EXACT_FIT
|
||||
*
|
||||
* @name Phaser.DOM.EXACT
|
||||
* @since 3.15.0
|
||||
*/
|
||||
EXACT_FIT: 0,
|
||||
EXACT: 0,
|
||||
|
||||
/**
|
||||
* A scale mode that prevents any scaling - see {@link Phaser.ScaleManager#scaleMode scaleMode}.
|
||||
*
|
||||
* @name Phaser.ScaleManager.NO_SCALE
|
||||
*
|
||||
* @name Phaser.DOM.FILL
|
||||
* @since 3.15.0
|
||||
*/
|
||||
NO_SCALE: 1,
|
||||
FILL: 1,
|
||||
|
||||
/**
|
||||
* A scale mode that shows the entire game while maintaining proportions - see {@link Phaser.ScaleManager#scaleMode scaleMode}.
|
||||
*
|
||||
* @name Phaser.ScaleManager.SHOW_ALL
|
||||
*
|
||||
* @name Phaser.DOM.CONTAIN
|
||||
* @since 3.15.0
|
||||
*/
|
||||
SHOW_ALL: 2,
|
||||
CONTAIN: 2,
|
||||
|
||||
/**
|
||||
* A scale mode that causes the Game size to change - see {@link Phaser.ScaleManager#scaleMode scaleMode}.
|
||||
*
|
||||
* @name Phaser.ScaleManager.RESIZE
|
||||
* @since 3.15.0
|
||||
*/
|
||||
RESIZE: 3,
|
||||
|
||||
/**
|
||||
* A scale mode that allows a custom scale factor - see {@link Phaser.ScaleManager#scaleMode scaleMode}.
|
||||
*
|
||||
* @name Phaser.ScaleManager.USER_SCALE
|
||||
* @name Phaser.DOM.RESIZE
|
||||
* @since 3.15.0
|
||||
*/
|
||||
USER_SCALE: 4,
|
||||
|
||||
/**
|
||||
* Names of the scale modes, indexed by value.
|
||||
*
|
||||
* @name Phaser.ScaleManager.MODES
|
||||
* @since 3.15.0
|
||||
* @type {string[]}
|
||||
*/
|
||||
MODES: [
|
||||
'EXACT_FIT',
|
||||
'NO_SCALE',
|
||||
'SHOW_ALL',
|
||||
'RESIZE',
|
||||
'USER_SCALE'
|
||||
]
|
||||
RESIZE: 3
|
||||
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -19,7 +19,7 @@ var StableSort = require('../utils/array/StableSort');
|
|||
*
|
||||
* @class DisplayList
|
||||
* @extends Phaser.Structs.List.<Phaser.GameObjects.GameObject>
|
||||
* @memberOf Phaser.GameObjects
|
||||
* @memberof Phaser.GameObjects
|
||||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
|
@ -138,46 +138,8 @@ 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.
|
||||
*
|
||||
* @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.
|
||||
* 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#getChildren
|
||||
* @since 3.12.0
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
@ -211,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.
|
||||
*
|
||||
|
@ -454,7 +494,7 @@ var GameObject = new Class({
|
|||
*/
|
||||
willRender: function (camera)
|
||||
{
|
||||
return !(GameObject.RENDER_MASK !== this.renderFlags || (this.cameraFilter > 0 && (this.cameraFilter & camera.id)));
|
||||
return !(GameObject.RENDER_MASK !== this.renderFlags || (this.cameraFilter !== 0 && (this.cameraFilter & camera.id)));
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -515,8 +555,9 @@ 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 (fromScene)
|
||||
|
@ -585,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
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
@ -308,7 +308,7 @@ var UpdateList = new Class({
|
|||
*
|
||||
* @name Phaser.GameObjects.UpdateList#length
|
||||
* @type {integer}
|
||||
* @readOnly
|
||||
* @readonly
|
||||
* @since 3.10.0
|
||||
*/
|
||||
length: {
|
||||
|
|
|
@ -11,7 +11,8 @@ 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.
|
||||
|
@ -59,7 +60,7 @@ var Render = require('./DynamicBitmapTextRender');
|
|||
*
|
||||
* @class DynamicBitmapText
|
||||
* @extends Phaser.GameObjects.BitmapText
|
||||
* @memberOf Phaser.GameObjects
|
||||
* @memberof Phaser.GameObjects
|
||||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
|
@ -149,6 +150,7 @@ var DynamicBitmapText = new Class({
|
|||
* @since 3.11.0
|
||||
*/
|
||||
this.callbackData = {
|
||||
parent: this,
|
||||
color: 0,
|
||||
tint: {
|
||||
topLeft: 0,
|
||||
|
|
|
@ -36,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;
|
||||
|
@ -61,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;
|
||||
|
@ -121,7 +121,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;
|
||||
|
|
|
@ -77,7 +77,7 @@ var Render = require('./BitmapTextRender');
|
|||
*
|
||||
* @class BitmapText
|
||||
* @extends Phaser.GameObjects.GameObject
|
||||
* @memberOf Phaser.GameObjects
|
||||
* @memberof Phaser.GameObjects
|
||||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
|
@ -137,7 +137,7 @@ var BitmapText = new Class({
|
|||
*
|
||||
* @name Phaser.GameObjects.BitmapText#font
|
||||
* @type {string}
|
||||
* @readOnly
|
||||
* @readonly
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.font = font;
|
||||
|
@ -149,7 +149,7 @@ var BitmapText = new Class({
|
|||
*
|
||||
* @name Phaser.GameObjects.BitmapText#fontData
|
||||
* @type {BitmapFontData}
|
||||
* @readOnly
|
||||
* @readonly
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.fontData = entry.data;
|
||||
|
@ -550,7 +550,7 @@ var BitmapText = new Class({
|
|||
*
|
||||
* @name Phaser.GameObjects.BitmapText#width
|
||||
* @type {number}
|
||||
* @readOnly
|
||||
* @readonly
|
||||
* @since 3.0.0
|
||||
*/
|
||||
width: {
|
||||
|
@ -569,7 +569,7 @@ var BitmapText = new Class({
|
|||
*
|
||||
* @name Phaser.GameObjects.BitmapText#height
|
||||
* @type {number}
|
||||
* @readOnly
|
||||
* @readonly
|
||||
* @since 3.0.0
|
||||
*/
|
||||
height: {
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue