mirror of
https://github.com/photonstorm/phaser
synced 2025-02-17 06:28:30 +00:00
Merge branch 'master' of https://github.com/photonstorm/phaser
This commit is contained in:
commit
38dc3bbd82
36 changed files with 1182 additions and 188 deletions
16
.travis.yml
Normal file
16
.travis.yml
Normal file
|
@ -0,0 +1,16 @@
|
|||
# https://travis-ci.org/photonstorm/
|
||||
|
||||
git:
|
||||
depth: 1
|
||||
|
||||
language: node_js
|
||||
node_js:
|
||||
- 'node'
|
||||
|
||||
env:
|
||||
- TERM=dumb
|
||||
|
||||
script:
|
||||
- yarn install
|
||||
- yarn run lint
|
||||
- yarn run build
|
21
CHANGELOG.md
21
CHANGELOG.md
|
@ -4,7 +4,9 @@
|
|||
|
||||
### New Features
|
||||
|
||||
* The new Render Texture Game Object is now available. You can clear, fill and draw texture frames to it. The Render Texture itself can be displayed in-game with its own transform, or you can use it as a Bitmap Mask for another Game Object.
|
||||
* Game.resize allows you to resize the game config, renderer and input system in one call.
|
||||
* When Game.resize is called it causes all Scene.Systems to have their resize method called. This is turn emits a `resize` event which your Scene can respond to. It will be sent the new width and height of the canvas as the only two parameters.
|
||||
* InputManager.resize allows you to update the bounds def and input scale in one call.
|
||||
* Game.Config.roundPixels property added to prevent sub-pixel interpolation during rendering of Game Objects in WebGL and Canvas.
|
||||
* Load.plugin now accepts a class as an argument as well as a URL string (thanks @nkholski)
|
||||
|
@ -13,6 +15,12 @@
|
|||
* GameObject.setInteractive has a new boolean argument `dropZone` which will allow you to set the object as being a drop zone right from the method.
|
||||
* Sprites can now be drop zones and have other Game Objects dragged onto them as targets.
|
||||
* The SceneManager has a new method: `remove` which allows you to remove and destroy a Scene, freeing up the Scene key for use by future scenes and potentially clearing the Scene from active memory for gc.
|
||||
* SceneManager.moveAbove will move a Scene to be directly above another Scene in the Scenes list. This is also exposed in the ScenePlugin.
|
||||
* SceneManager.moveBelow will move a Scene to be directly below another Scene in the Scenes list. This is also exposed in the ScenePlugin.
|
||||
* Quadratic Bezier Interpolation has been added to the Math.Interpolation functions (thanks @RiCoTeRoX)
|
||||
* A new Quadratic Bezier Curve class has been added, expanding the available Curve types (thanks @RiCoTeRoX)
|
||||
* Path.quadraticBezierTo allows you to add a Quadratic Bezier Curve into your Path.
|
||||
* Loader.multiatlas now supports Texture Packers new JSON atlas format which exports one combined atlas for all image files. This is available if you use the new Phaser 3 Export from within Texture Packer (thanks @CodeAndWeb)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
|
@ -26,6 +34,10 @@
|
|||
* InputPlugin.clear now properly removes a Game Object from all internal arrays, not just the _list.
|
||||
* InputPlugin.processOverOut no longer considers an item as being 'out' if it's in the internal `_drag` array.
|
||||
* When a Game Object is scaled, its Arcade Physics body was still calculating its position based on its original size instead of scaled one (thanks @pixelpicosean)
|
||||
* The RandomDataGenerator classes randomness has been improved thanks to the correct caching of a class property. Fix #3289 (thanks @migiyubi)
|
||||
* The RandomDataGenerator `sign` property had a method collision. Fix #3323 (thanks @vinerz and @samme)
|
||||
* In Arcade Physics World if you collided a group with itself it would call a missing method (`collideGroupVsSelf`), it now calls `collideGroupVsGroup` correctly (thanks @patrickgalbraith)
|
||||
* The HTML5 Sound Manager would unlock the Sound API on a touch event but only if the audio files were loaded in the first Scene, if they were loaded in a subsequent Scene the audio system would never unlock. It now unlocks only if there are audio files in the cache. Fix #3311 (thanks @chancezeus)
|
||||
|
||||
### Updates
|
||||
|
||||
|
@ -37,9 +49,12 @@
|
|||
* If you set `transparent` in the Game Config but didn't provide a `backgroundColor` then it would render as black. It will now be properly transparent. If you do provide a color value then it must include an alpha component.
|
||||
* You can now pass normal Groups to Arcade Physics collide / overlap, as well as Physics Groups. Fix #3277 (thanks @nkholski)
|
||||
* Texture.get has been optimized to fail first, then error, with a new falsey check. This allows you to skip out specifying animation frames in the animation config without generating a console warning.
|
||||
|
||||
* Documentation updates: thanks to @melissaelopez @samme
|
||||
|
||||
* The `setFrame` method of the Texture component has been updated so that it will now automatically reset the `width` and `height` of a Game Object to match that of the new Frame. Related, it will also adjust the display origin values, because they are size based. If the Frame has a custom pivot it will set the origin to match the custom pivot instead.
|
||||
* ScenePlugin.swapPosition now allows you to use it to swap the positions of any two Scenes. Before the change it only allowed you to swap the position of the calling Scene and another one, but a new optional `keyB` argument opens this up.
|
||||
* The SceneManager no longer renders a Scene unless it is visible AND either running or paused. This now skips Scenes that are in an `init` state.
|
||||
* The Keyboard Manager will now no longer emit `keydown` events if you keep holding a key down. Fix #3239 (thanks @squaresun)
|
||||
* Phaser is now running Travis CI build testing again (thanks @vpmedia)
|
||||
* Documentation updates: thanks to @melissaelopez @samme @jblang94
|
||||
|
||||
## Version 3.1.2 - 23rd February 2018
|
||||
|
||||
|
|
44
README.md
44
README.md
|
@ -2,13 +2,13 @@
|
|||
|
||||
![Phaser Header](https://phaser.io/images/github/300/phaser-header.png "Phaser 3 Header Banner")
|
||||
|
||||
Phaser is a fast, free, and fun open source HTML5 game framework. It offers WebGL and Canvas rendering across desktop and mobile web browsers. Games can be compiled to iOS, Android and native apps via 3rd party tools. You can use JavaScript or TypeScript for development.
|
||||
Phaser is a fast, free, and fun open source HTML5 game framework that offers WebGL and Canvas rendering across desktop and mobile web browsers. Games can be compiled to iOS, Android and native apps by using 3rd party tools. You can use JavaScript or TypeScript for development.
|
||||
|
||||
Phaser is available in two versions: Phaser 3 and [Phaser CE - The Community Edition](https://github.com/photonstorm/phaser-ce). Phaser CE is a community-lead continuation of the Phaser 2 codebase and is hosted on its own repo. Phaser 3 is the next generation of Phaser.
|
||||
Phaser is available in two versions: Phaser 3 and [Phaser CE - The Community Edition](https://github.com/photonstorm/phaser-ce). Phaser CE is a community-lead continuation of the Phaser 2 codebase and is hosted on a separate repo. Phaser 3 is the next generation of Phaser.
|
||||
|
||||
Along with the fantastic open source community, Phaser is actively developed and maintained by [Photon Storm](http://www.photonstorm.com). As a result of rapid support, and a developer friendly API, Phaser is currently one of the [most starred](https://github.com/collections/javascript-game-engines) game frameworks on GitHub.
|
||||
|
||||
Thousands of developers worldwide use Phaser. From indies and multi-national digital agencies, to schools and Universities. Each creating their own incredible [games](https://phaser.io/games/).
|
||||
Thousands of developers from indie and multi-national digital agencies, and universities worldwide use Phaser. You can take a look at their incredible [games](https://phaser.io/games/).
|
||||
|
||||
**Visit:** The [Phaser website](https://phaser.io) and follow on [Twitter](https://twitter.com/phaser_) (#phaserjs)<br />
|
||||
**Learn:** [API Docs](https://github.com/photonstorm/phaser3-docs), [Support Forum][forum] and [StackOverflow](https://stackoverflow.com/questions/tagged/phaser-framework)<br />
|
||||
|
@ -18,7 +18,7 @@ Thousands of developers worldwide use Phaser. From indies and multi-national dig
|
|||
**Extend:** With [Phaser Plugins](https://phaser.io/shop/plugins)<br />
|
||||
**Be awesome:** [Support](#support) the future of Phaser<br />
|
||||
|
||||
Grab the source and join in the fun!
|
||||
Grab the source and join the fun!
|
||||
|
||||
![What's New](https://phaser.io/images/github/div-whats-new.png "What's New")
|
||||
|
||||
|
@ -68,9 +68,9 @@ Extra special thanks to our top-tier sponsors: [Orange Games](http://orangegames
|
|||
|
||||
<div align="center"><img src="https://phaser.io/images/github/phaser-world.png"></div>
|
||||
|
||||
Every Monday we publish the [Phaser World](https://phaser.io/community/newsletter) newsletter. It's packed full of the latest Phaser games, tutorials, videos, meet-ups, talks, and more. It also contains our weekly Development Progress updates, where you can read about what new features we've been working on.
|
||||
Every Monday we publish the [Phaser World](https://phaser.io/community/newsletter) newsletter. It's packed full of the latest Phaser games, tutorials, videos, meet-ups, talks, and more. The newsletter also contains our weekly Development Progress updates which let you know about the new features we're working on.
|
||||
|
||||
Over 100 previous editions can found on our [Back Issues](http://phaser.io/community/backissues) page.
|
||||
Over 100 previous editions can be found on our [Back Issues](http://phaser.io/community/backissues) page.
|
||||
|
||||
![Download Phaser](https://phaser.io/images/github/div-download.png "Download Phaser")
|
||||
<a name="download"></a>
|
||||
|
@ -91,7 +91,9 @@ npm install phaser
|
|||
|
||||
### CDN
|
||||
|
||||
[Phaser is on jsDelivr](http://www.jsdelivr.com/projects/phaser), a "super-fast CDN for developers". Include the following in your html:
|
||||
[![](https://data.jsdelivr.com/v1/package/gh/photonstorm/phaser/badge)](https://www.jsdelivr.com/package/gh/photonstorm/phaser)
|
||||
|
||||
[Phaser is on jsDelivr](http://www.jsdelivr.com/projects/phaser) which is a "super-fast CDN for developers". Include the following in your html:
|
||||
|
||||
```html
|
||||
<script src="//cdn.jsdelivr.net/npm/phaser@3.1.2/dist/phaser.js"></script>
|
||||
|
@ -112,7 +114,7 @@ Phaser is released under the [MIT License](https://opensource.org/licenses/MIT).
|
|||
|
||||
<img src="https://phaser.io/images/github/learn.jpg" align="right">
|
||||
|
||||
Phaser 3 is so brand new the paint is still wet, but tutorials and guides are starting to come out!
|
||||
Phaser 3 is so brand new the "paint is still wet", but tutorials and guides are starting to come out!
|
||||
|
||||
* [Getting Started with Phaser 3](https://phaser.io/tutorials/getting-started-phaser3) (useful if you are completely new to Phaser)
|
||||
* [Making your first Phaser 3 Game](https://phaser.io/tutorials/making-your-first-phaser-3-game)
|
||||
|
@ -122,7 +124,7 @@ Also, please subscribe to the [Phaser World](https://phaser.io/community/newslet
|
|||
|
||||
### Source Code Examples
|
||||
|
||||
During our development of Phaser 3 we created hundreds of examples, with the full source code and assets available. Until those are fully integrated with the Phaser web site, you'll have to browse them in the [Phaser 3 Labs](http://labs.phaser.io), or clone the [examples repo][examples]. Note: Not all examples work, sorry! We're tidying them up as fast as we can.
|
||||
During our development of Phaser 3, we created hundreds of examples with the full source code and assets. Until these examples are fully integrated into the Phaser website, you can browse them on [Phaser 3 Labs](http://labs.phaser.io), or clone the [examples repo][examples]. Note: Not all examples work, sorry! We're tidying them up as fast as we can.
|
||||
|
||||
### Create Your First Phaser 3 Example
|
||||
|
||||
|
@ -142,7 +144,7 @@ Create an `index.html` page locally and paste the following code into it:
|
|||
</html>
|
||||
```
|
||||
|
||||
This is a standard empty web page. You'll notice it's pulling in a build of Phaser 3 in the script tag, but otherwise doesn't do anything yet. Now let's set-up the game config. Paste the following between the `<script></script>` tags:
|
||||
This is a standard empty webpage. You'll notice there's a script tag that is pulling in a build of Phaser 3, but otherwise this webpage doesn't do anything yet. Now let's set-up the game config. Paste the following between the `<script></script>` tags:
|
||||
|
||||
```javascript
|
||||
var config = {
|
||||
|
@ -162,7 +164,7 @@ var config = {
|
|||
};
|
||||
```
|
||||
|
||||
This is a pretty standard Phaser 3 Game Configuration object. We'll tell it to use the WebGL renderer if it can, set the canvas to a size of 800x600 pixels, enable Arcade Physics and finally call the `preload` and `create` functions. These don't exist yet, so if you run this it will just error. So add the following after the config object:
|
||||
`config` is a pretty standard Phaser 3 Game Configuration object. We tell `config` to use the WebGL renderer if it can, set the canvas to a size of 800x600 pixels, enable Arcade Physics, and finally call the `preload` and `create` functions. `preload` and `create` have not been implemented yet, so if you run this JavaScript code, you will have an error. Add the following after `config`:
|
||||
|
||||
```javascript
|
||||
var game = new Phaser.Game(config);
|
||||
|
@ -181,9 +183,9 @@ function create ()
|
|||
}
|
||||
```
|
||||
|
||||
This creates a Phaser Game instance, using our configuration object. It also provides the two functions it needs. The `preload` function is a way to easily load assets into your game. Here we'll set the Base URL to be the Phaser server and grab down 3 PNG files.
|
||||
`game` is a Phaser Game instance that uses our configuration object `config`. We also add function definitions for `preload` and `create`. The `preload` function helps you easily load assets into your game. In `preload`, we set the Base URL to be the Phaser server and load 3 PNG files.
|
||||
|
||||
The create function is empty, so it's time to fill it in:
|
||||
The `create` function is empty, so it's time to fill it in:
|
||||
|
||||
```javascript
|
||||
function create ()
|
||||
|
@ -208,9 +210,9 @@ function create ()
|
|||
}
|
||||
```
|
||||
|
||||
Here we're adding the sky image into the game. Over the top of this we have created a Particle Emitter. The `scale` value means the particles will start large and then scale away to nothing over the duration of their lifespan.
|
||||
Here we add a sky image into the game and create a Particle Emitter. The `scale` value means that the particles will initially be large and will shrink to nothing as their lifespan progresses.
|
||||
|
||||
Then we add the logo image. Notice how this is a Physics Image, which means it is given a physics body by default. We set some properties on it: velocity, bounce (or restitution) and collision with the world bounds. This will make our logo bounce around the screen. Finally, we tell the particle emitter to follow the logo - so as it moves, the particles will flow from it.
|
||||
After creating the `emitter`, we add a logo image called `logo`. Since `logo` is a Physics Image, `logo` is given a physics body by default. We set some properties for `logo`: velocity, bounce (or restitution), and collision with the world bounds. These properties will make our logo bounce around the screen. Finally, we tell the particle emitter to follow the logo - so as the logo moves, the particles will flow from it.
|
||||
|
||||
Run it in your browser and you'll see the following:
|
||||
|
||||
|
@ -218,23 +220,23 @@ Run it in your browser and you'll see the following:
|
|||
|
||||
(Got an error? Here's the [full code](https://gist.github.com/photonstorm/46cb8fb4b19fc7717dcad514cdcec064))
|
||||
|
||||
It's just a tiny example, and we've hundreds more for you to explore, but hopefully it shows how expressive and quick Phaser is to use. With just a few easily readable lines of code we've got something pretty impressive up on screen!
|
||||
This is a tiny example, and there are hundreds more for you to explore, but hopefully it shows how expressive and quick Phaser is to use. With just a few easily readable lines of code, we've got something pretty impressive up on screen!
|
||||
|
||||
Subscribe to our weekly newsletter for further tutorials and examples.
|
||||
|
||||
![Building Phaser](https://phaser.io/images/github/div-building-phaser.png "Building Phaser")
|
||||
|
||||
Phaser is provided ready compiled in the `dist` folder of the repository. There are both plain and minified versions. The plain version is for use during development, and the minified version for production. You can also create your own builds.
|
||||
There are both plain and minified compiled versions of Phaser in the `dist` folder of the repository. The plain version is for use during development, and the minified version is for production use. You can also create your own builds.
|
||||
|
||||
### Custom Builds
|
||||
|
||||
Phaser 3 has to be built using Webpack. We take advantage of a number of Webpack features and plugins to allow us to properly tailor the build process. You can also elect exactly which features are bundled into your version of Phaser. We will release a tutorial covering the process shortly, but for now please look at our webpack config files to get an idea of the settings required.
|
||||
Phaser 3 must be built using Webpack. We take advantage of a number of Webpack features and plugins which allow us to properly tailor the build process. You can elect exactly which features are bundled into your version of Phaser. We will release a tutorial covering the process shortly, but for now please look at our webpack config files to get an idea of the required settings.
|
||||
|
||||
### Building from source
|
||||
### Building from Source
|
||||
|
||||
Should 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`.
|
||||
|
||||
You can then run `webpack` to perform a dev build to the `build` folder, including source maps for local testing, or run `npm run dist` to create a minified packaged build into the `dist` folder.
|
||||
You can then run `webpack` to create a development build in the `build` folder which includes source maps for local testing. You can also run `npm run dist` to create a minified packaged build in the `dist` folder.
|
||||
|
||||
![Change Log](https://phaser.io/images/github/div-change-log.png "Change Log")
|
||||
<a name="changelog"></a>
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
"watch": "webpack --watch",
|
||||
"dist": "webpack --config webpack.dist.config.js",
|
||||
"lint": "eslint --config .eslintrc.json \"src/**/*.js\"",
|
||||
"lintfix": "eslint --config .eslintrc.json \"src/**/*.js\" --fix",
|
||||
"sloc": "node-sloc './src' --include-extensions \"js\""
|
||||
},
|
||||
"keywords": [
|
||||
|
|
192
src/curves/QuadraticBezierCurve.js
Normal file
192
src/curves/QuadraticBezierCurve.js
Normal file
|
@ -0,0 +1,192 @@
|
|||
/**
|
||||
* @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 Curve = require('./Curve');
|
||||
var QuadraticBezierInterpolation = require('../math/interpolation/QuadraticBezierInterpolation');
|
||||
var Vector2 = require('../math/Vector2');
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* [description]
|
||||
*
|
||||
* @class QuadraticBezier
|
||||
* @extends Phaser.Curves.Curve
|
||||
* @memberOf Phaser.Curves
|
||||
* @constructor
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param {Phaser.Math.Vector2|Phaser.Math.Vector2[]} p0 - Start point, or an array of point pairs.
|
||||
* @param {Phaser.Math.Vector2} p1 - Control Point 1.
|
||||
* @param {Phaser.Math.Vector2} p2 - Control Point 2.
|
||||
*/
|
||||
var QuadraticBezier = new Class({
|
||||
|
||||
Extends: Curve,
|
||||
|
||||
initialize:
|
||||
|
||||
function QuadraticBezier (p0, p1, p2)
|
||||
{
|
||||
Curve.call(this, 'QuadraticBezier');
|
||||
|
||||
if (Array.isArray(p0))
|
||||
{
|
||||
p2 = new Vector2(p0[4], p0[5]);
|
||||
p1 = new Vector2(p0[2], p0[3]);
|
||||
p0 = new Vector2(p0[0], p0[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @name Phaser.Curves.QuadraticBezier#p0
|
||||
* @type {Phaser.Math.Vector2}
|
||||
* @since 3.2.0
|
||||
*/
|
||||
this.p0 = p0;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @name Phaser.Curves.QuadraticBezier#p1
|
||||
* @type {Phaser.Math.Vector2}
|
||||
* @since 3.2.0
|
||||
*/
|
||||
this.p1 = p1;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @name Phaser.Curves.QuadraticBezier#p2
|
||||
* @type {Phaser.Math.Vector2}
|
||||
* @since 3.2.0
|
||||
*/
|
||||
this.p2 = p2;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.QuadraticBezier#getStartPoint
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param {Phaser.Math.Vector2} out - [description]
|
||||
*
|
||||
* @return {Phaser.Math.Vector2} [description]
|
||||
*/
|
||||
getStartPoint: function (out)
|
||||
{
|
||||
if (out === undefined) { out = new Vector2(); }
|
||||
|
||||
return out.copy(this.p0);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.QuadraticBezier#getResolution
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param {number} divisions - [description]
|
||||
*
|
||||
* @return {number} [description]
|
||||
*/
|
||||
getResolution: function (divisions)
|
||||
{
|
||||
return divisions;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.QuadraticBezier#getPoint
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param {number} t - [description]
|
||||
* @param {Phaser.Math.Vector2} [out] - [description]
|
||||
*
|
||||
* @return {Phaser.Math.Vector2} [description]
|
||||
*/
|
||||
getPoint: function (t, out)
|
||||
{
|
||||
if (out === undefined) { out = new Vector2(); }
|
||||
|
||||
var p0 = this.p0;
|
||||
var p1 = this.p1;
|
||||
var p2 = this.p2;
|
||||
|
||||
return out.set(
|
||||
QuadraticBezierInterpolation(t, p0.x, p1.x, p2.x),
|
||||
QuadraticBezierInterpolation(t, p0.y, p1.y, p2.y)
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.QuadraticBezier#draw
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.Graphics} graphics - [description]
|
||||
* @param {integer} [pointsTotal=32] - [description]
|
||||
*
|
||||
* @return {Phaser.GameObjects.Graphics} [description]
|
||||
*/
|
||||
draw: function (graphics, pointsTotal)
|
||||
{
|
||||
if (pointsTotal === undefined) { pointsTotal = 32; }
|
||||
|
||||
var points = this.getPoints(pointsTotal);
|
||||
|
||||
graphics.beginPath();
|
||||
graphics.moveTo(this.p0.x, this.p0.y);
|
||||
|
||||
for (var i = 1; i < points.length; i++)
|
||||
{
|
||||
graphics.lineTo(points[i].x, points[i].y);
|
||||
}
|
||||
|
||||
graphics.strokePath();
|
||||
|
||||
// So you can chain graphics calls
|
||||
return graphics;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.QuadraticBezier#toJSON
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @return {object} [description]
|
||||
*/
|
||||
toJSON: function ()
|
||||
{
|
||||
return {
|
||||
type: this.type,
|
||||
points: [
|
||||
this.p0.x, this.p0.y,
|
||||
this.p1.x, this.p1.y,
|
||||
this.p2.x, this.p2.y
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
QuadraticBezier.fromJSON = function (data)
|
||||
{
|
||||
var points = data.points;
|
||||
|
||||
var p0 = new Vector2(points[0], points[1]);
|
||||
var p1 = new Vector2(points[2], points[3]);
|
||||
var p2 = new Vector2(points[4], points[5]);
|
||||
|
||||
return new QuadraticBezier(p0, p1, p2);
|
||||
};
|
||||
|
||||
module.exports = QuadraticBezier;
|
|
@ -9,13 +9,12 @@
|
|||
*/
|
||||
|
||||
module.exports = {
|
||||
|
||||
Path: require('./path/Path'),
|
||||
|
||||
CubicBezier: require('./CubicBezierCurve'),
|
||||
Curve: require('./Curve'),
|
||||
Ellipse: require('./EllipseCurve'),
|
||||
Line: require('./LineCurve'),
|
||||
QuadraticBezier: require('./QuadraticBezierCurve'),
|
||||
Spline: require('./SplineCurve')
|
||||
|
||||
};
|
||||
|
|
|
@ -12,6 +12,7 @@ var EllipseCurve = require('../EllipseCurve');
|
|||
var GameObjectFactory = require('../../gameobjects/GameObjectFactory');
|
||||
var LineCurve = require('../LineCurve');
|
||||
var MovePathTo = require('./MoveTo');
|
||||
var QuadraticBezierCurve = require('../QuadraticBezierCurve');
|
||||
var Rectangle = require('../../geom/rectangle/Rectangle');
|
||||
var SplineCurve = require('../SplineCurve');
|
||||
var Vector2 = require('../../math/Vector2');
|
||||
|
@ -140,8 +141,8 @@ var Path = new Class({
|
|||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} radius - [description]
|
||||
* @param {boolean} [clockwise] - [description]
|
||||
* @param {number} [rotation] - [description]
|
||||
* @param {boolean} [clockwise=false] - [description]
|
||||
* @param {number} [rotation=0] - [description]
|
||||
*
|
||||
* @return {Phaser.Curves.Path} [description]
|
||||
*/
|
||||
|
@ -185,10 +186,10 @@ var Path = new Class({
|
|||
*
|
||||
* @param {number} x - [description]
|
||||
* @param {number} y - [description]
|
||||
* @param {Phaser.Math.Vector2} control1X - {Phaser.Math[description]
|
||||
* @param {Phaser.Math.Vector2} control1Y - {Phaser.Math[description]
|
||||
* @param {Phaser.Math.Vector2} control2X - {Phaser.Math[description]
|
||||
* @param {Phaser.Math.Vector2} control2Y - {Phaser.Math[description]
|
||||
* @param {Phaser.Math.Vector2} control1X - [description]
|
||||
* @param {Phaser.Math.Vector2} control1Y - [description]
|
||||
* @param {Phaser.Math.Vector2} control2X - [description]
|
||||
* @param {Phaser.Math.Vector2} control2Y - [description]
|
||||
*
|
||||
* @return {Phaser.Curves.Path} [description]
|
||||
*/
|
||||
|
@ -216,17 +217,40 @@ var Path = new Class({
|
|||
return this.add(new CubicBezierCurve(p0, p1, p2, p3));
|
||||
},
|
||||
|
||||
// Creates a quadratic bezier curve starting at the previous end point and ending at p2, using p1 as a control point
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.Path#destroy
|
||||
* @since 3.0.0
|
||||
* @method Phaser.Curves.Path#quadraticBezierTo
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param {number|Phaser.Math.Vector2[]} x - [description]
|
||||
* @param {number} [y] - [description]
|
||||
* @param {number} [controlX] - [description]
|
||||
* @param {number} [controlY] - [description]
|
||||
*
|
||||
* @return {Phaser.Curves.Path} [description]
|
||||
*/
|
||||
destroy: function ()
|
||||
quadraticBezierTo: function (x, y, controlX, controlY)
|
||||
{
|
||||
this.curves.length = 0;
|
||||
this.cacheLengths.length = 0;
|
||||
this.startPoint = undefined;
|
||||
var p0 = this.getEndPoint();
|
||||
var p1;
|
||||
var p2;
|
||||
|
||||
// Assume they're all vec2s
|
||||
if (x instanceof Vector2)
|
||||
{
|
||||
p1 = x;
|
||||
p2 = y;
|
||||
}
|
||||
else
|
||||
{
|
||||
p1 = new Vector2(controlX, controlY);
|
||||
p2 = new Vector2(x, y);
|
||||
}
|
||||
|
||||
return this.add(new QuadraticBezierCurve(p0, p1, p2));
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -331,6 +355,10 @@ var Path = new Class({
|
|||
case 'CubicBezierCurve':
|
||||
this.add(CubicBezierCurve.fromJSON(curve));
|
||||
break;
|
||||
|
||||
case 'QuadraticBezierCurve':
|
||||
this.add(QuadraticBezierCurve.fromJSON(curve));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -425,9 +453,9 @@ var Path = new Class({
|
|||
* @method Phaser.Curves.Path#getEndPoint
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Math.Vector2} [out] - {Phaser.Math[description]
|
||||
* @param {Phaser.Math.Vector2} [out] - [description]
|
||||
*
|
||||
* @return {Phaser.Math.Vector2} {Phaser.Math[description]
|
||||
* @return {Phaser.Math.Vector2} [description]
|
||||
*/
|
||||
getEndPoint: function (out)
|
||||
{
|
||||
|
@ -476,7 +504,7 @@ var Path = new Class({
|
|||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} t - [description]
|
||||
* @param {Phaser.Math.Vector2} [out] - {Phaser.Math[description]
|
||||
* @param {Phaser.Math.Vector2} [out] - [description]
|
||||
*
|
||||
* @return {Phaser.Math.Vector2|null} [description]
|
||||
*/
|
||||
|
@ -568,9 +596,9 @@ var Path = new Class({
|
|||
* @method Phaser.Curves.Path#getRandomPoint
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Math.Vector2} [out] - {Phaser.Math[description]
|
||||
* @param {Phaser.Math.Vector2} [out] - [description]
|
||||
*
|
||||
* @return {Phaser.Math.Vector2} {Phaser.Math[description]
|
||||
* @return {Phaser.Math.Vector2} [description]
|
||||
*/
|
||||
getRandomPoint: function (out)
|
||||
{
|
||||
|
@ -614,9 +642,9 @@ var Path = new Class({
|
|||
* @method Phaser.Curves.Path#getStartPoint
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Math.Vector2} [out] - {Phaser.Math[description]
|
||||
* @param {Phaser.Math.Vector2} [out] - [description]
|
||||
*
|
||||
* @return {Phaser.Math.Vector2} {Phaser.Math[description]
|
||||
* @return {Phaser.Math.Vector2} [description]
|
||||
*/
|
||||
getStartPoint: function (out)
|
||||
{
|
||||
|
@ -633,7 +661,7 @@ var Path = new Class({
|
|||
* @method Phaser.Curves.Path#lineTo
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number|Phaser.Math.Vector2} x - {Phaser.Math[description]
|
||||
* @param {number|Phaser.Math.Vector2} x - [description]
|
||||
* @param {number} [y] - [description]
|
||||
*
|
||||
* @return {Phaser.Curves.Path} [description]
|
||||
|
@ -728,6 +756,19 @@ var Path = new Class({
|
|||
this.cacheLengths = [];
|
||||
|
||||
this.getCurveLengths();
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.Path#destroy
|
||||
* @since 3.0.0
|
||||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
this.curves.length = 0;
|
||||
this.cacheLengths.length = 0;
|
||||
this.startPoint = undefined;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -1,20 +1,77 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Provides methods used for getting and setting the transform values of a Game Object.
|
||||
* Should be applied as a mixin and not used directly.
|
||||
*
|
||||
* @name Phaser.GameObjects.Components.MatrixStack
|
||||
* @since 3.2.0
|
||||
*/
|
||||
|
||||
var MatrixStack = {
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @name Phaser.GameObjects.Components.MatrixStack#matrixStack
|
||||
* @type {Float32Array}
|
||||
* @private
|
||||
* @since 3.2.0
|
||||
*/
|
||||
matrixStack: null,
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @name Phaser.GameObjects.Components.MatrixStack#currentMatrix
|
||||
* @type {Float32Array}
|
||||
* @private
|
||||
* @since 3.2.0
|
||||
*/
|
||||
currentMatrix: null,
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @name Phaser.GameObjects.Components.MatrixStack#currentMatrixIndex
|
||||
* @type {integer}
|
||||
* @private
|
||||
* @since 3.2.0
|
||||
*/
|
||||
currentMatrixIndex: 0,
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.MatrixStack#initMatrixStack
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
|
||||
*/
|
||||
initMatrixStack: function ()
|
||||
{
|
||||
this.matrixStack = new Float32Array(6000); // up to 1000 matrices
|
||||
this.currentMatrix = new Float32Array([1.0, 0.0, 0.0, 1.0, 0.0, 0.0]);
|
||||
this.currentMatrix = new Float32Array([ 1.0, 0.0, 0.0, 1.0, 0.0, 0.0 ]);
|
||||
this.currentMatrixIndex = 0;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.MatrixStack#save
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
|
||||
*/
|
||||
save: function ()
|
||||
{
|
||||
if (this.currentMatrixIndex >= this.matrixStack.length) return this;
|
||||
if (this.currentMatrixIndex >= this.matrixStack.length) { return this; }
|
||||
|
||||
var matrixStack = this.matrixStack;
|
||||
var currentMatrix = this.currentMatrix;
|
||||
|
@ -31,9 +88,17 @@ var MatrixStack = {
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.MatrixStack#restore
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
|
||||
*/
|
||||
restore: function ()
|
||||
{
|
||||
if (this.currentMatrixIndex <= 0) return this;
|
||||
if (this.currentMatrixIndex <= 0) { return this; }
|
||||
|
||||
this.currentMatrixIndex -= 6;
|
||||
|
||||
|
@ -51,12 +116,36 @@ var MatrixStack = {
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.MatrixStack#loadIdentity
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
|
||||
*/
|
||||
loadIdentity: function ()
|
||||
{
|
||||
this.setTransform(1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.MatrixStack#transform
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param {number} a - [description]
|
||||
* @param {number} b - [description]
|
||||
* @param {number} c - [description]
|
||||
* @param {number} d - [description]
|
||||
* @param {number} tx - [description]
|
||||
* @param {number} ty - [description]
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
|
||||
*/
|
||||
transform: function (a, b, c, d, tx, ty)
|
||||
{
|
||||
var currentMatrix = this.currentMatrix;
|
||||
|
@ -77,6 +166,21 @@ var MatrixStack = {
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.MatrixStack#setTransform
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param {number} a - [description]
|
||||
* @param {number} b - [description]
|
||||
* @param {number} c - [description]
|
||||
* @param {number} d - [description]
|
||||
* @param {number} tx - [description]
|
||||
* @param {number} ty - [description]
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
|
||||
*/
|
||||
setTransform: function (a, b, c, d, tx, ty)
|
||||
{
|
||||
var currentMatrix = this.currentMatrix;
|
||||
|
@ -91,6 +195,17 @@ var MatrixStack = {
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.MatrixStack#translate
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param {number} x - [description]
|
||||
* @param {number} y - [description]
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
|
||||
*/
|
||||
translate: function (x, y)
|
||||
{
|
||||
var currentMatrix = this.currentMatrix;
|
||||
|
@ -107,6 +222,17 @@ var MatrixStack = {
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.MatrixStack#scale
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param {number} x - [description]
|
||||
* @param {number} y - [description]
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
|
||||
*/
|
||||
scale: function (x, y)
|
||||
{
|
||||
var currentMatrix = this.currentMatrix;
|
||||
|
@ -123,6 +249,16 @@ var MatrixStack = {
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.MatrixStack#rotate
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param {number} t - The angle of rotation, in radians.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
|
||||
*/
|
||||
rotate: function (t)
|
||||
{
|
||||
var currentMatrix = this.currentMatrix;
|
||||
|
|
|
@ -16,6 +16,17 @@
|
|||
|
||||
var Origin = {
|
||||
|
||||
/**
|
||||
* A property indicating that a Game Object has this component.
|
||||
*
|
||||
* @name Phaser.GameObjects.Components.Origin#_originComponent
|
||||
* @type {boolean}
|
||||
* @private
|
||||
* @default true
|
||||
* @since 3.2.0
|
||||
*/
|
||||
_originComponent: true,
|
||||
|
||||
/**
|
||||
* The horizontal origin of this Game Object.
|
||||
* The origin maps the relationship between the size and position of the Game Object.
|
||||
|
|
|
@ -13,6 +13,17 @@
|
|||
|
||||
var Size = {
|
||||
|
||||
/**
|
||||
* A property indicating that a Game Object has this component.
|
||||
*
|
||||
* @name Phaser.GameObjects.Components.Size#_sizeComponent
|
||||
* @type {boolean}
|
||||
* @private
|
||||
* @default true
|
||||
* @since 3.2.0
|
||||
*/
|
||||
_sizeComponent: true,
|
||||
|
||||
/**
|
||||
* The native (un-scaled) width of this Game Object.
|
||||
*
|
||||
|
|
|
@ -60,6 +60,9 @@ var Texture = {
|
|||
* The Frame has to belong to the current Texture being used.
|
||||
*
|
||||
* It can be either a string or an index.
|
||||
*
|
||||
* Calling `setFrame` will modify the `width` and `height` properties of your Game Object.
|
||||
* It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Texture#setFrame
|
||||
* @since 3.0.0
|
||||
|
@ -81,9 +84,21 @@ var Texture = {
|
|||
this.renderFlags |= _FLAG;
|
||||
}
|
||||
|
||||
if (this.frame.customPivot)
|
||||
if (this._sizeComponent)
|
||||
{
|
||||
this.setOrigin(this.frame.pivotX, this.frame.pivotY);
|
||||
this.setSizeToFrame();
|
||||
}
|
||||
|
||||
if (this._originComponent)
|
||||
{
|
||||
if (this.frame.customPivot)
|
||||
{
|
||||
this.setOrigin(this.frame.pivotX, this.frame.pivotY);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.updateDisplayOrigin();
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
|
|
|
@ -1,11 +1,49 @@
|
|||
/**
|
||||
* @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 CanvasPool = require('../../display/canvas/CanvasPool');
|
||||
var Class = require('../../utils/Class');
|
||||
var Components = require('../components');
|
||||
var CONST = require('../../const');
|
||||
var GameObject = require('../GameObject');
|
||||
var RenderTextureWebGL = require('./RenderTextureWebGL');
|
||||
var RenderTextureCanvas = require('./RenderTextureCanvas');
|
||||
var Render = require('./RenderTextureRender');
|
||||
var CanvasPool = require('../../display/canvas/CanvasPool');
|
||||
var RenderTextureCanvas = require('./RenderTextureCanvas');
|
||||
var RenderTextureWebGL = require('./RenderTextureWebGL');
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* A Render Texture.
|
||||
*
|
||||
* @class RenderTexture
|
||||
* @extends Phaser.GameObjects.GameObject
|
||||
* @memberOf Phaser.GameObjects
|
||||
* @constructor
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @extends Phaser.GameObjects.Components.Alpha
|
||||
* @extends Phaser.GameObjects.Components.BlendMode
|
||||
* @extends Phaser.GameObjects.Components.Depth
|
||||
* @extends Phaser.GameObjects.Components.Flip
|
||||
* @extends Phaser.GameObjects.Components.GetBounds
|
||||
* @extends Phaser.GameObjects.Components.MatrixStack
|
||||
* @extends Phaser.GameObjects.Components.Origin
|
||||
* @extends Phaser.GameObjects.Components.Pipeline
|
||||
* @extends Phaser.GameObjects.Components.ScaleMode
|
||||
* @extends Phaser.GameObjects.Components.ScrollFactor
|
||||
* @extends Phaser.GameObjects.Components.Size
|
||||
* @extends Phaser.GameObjects.Components.Tint
|
||||
* @extends Phaser.GameObjects.Components.Transform
|
||||
* @extends Phaser.GameObjects.Components.Visible
|
||||
*
|
||||
* @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time.
|
||||
* @param {number} x - The horizontal position of this Game Object in the world.
|
||||
* @param {number} y - The vertical position of this Game Object in the world.
|
||||
* @param {integer} [width=32] - The width of the Render Texture.
|
||||
* @param {integer} [height=32] - The height of the Render Texture.
|
||||
*/
|
||||
var RenderTexture = new Class({
|
||||
|
||||
Extends: GameObject,
|
||||
|
@ -30,14 +68,18 @@ var RenderTexture = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
function RenderTexture(scene, x, y, width, height)
|
||||
function RenderTexture (scene, x, y, width, height)
|
||||
{
|
||||
if (width === undefined) { width = 32; }
|
||||
if (height === undefined) { height = 32; }
|
||||
|
||||
GameObject.call(this, scene, 'RenderTexture');
|
||||
|
||||
this.initMatrixStack();
|
||||
|
||||
this.renderer = scene.sys.game.renderer;
|
||||
|
||||
if (this.renderer.type === Phaser.WEBGL)
|
||||
if (this.renderer.type === CONST.WEBGL)
|
||||
{
|
||||
var gl = this.renderer.gl;
|
||||
this.gl = gl;
|
||||
|
@ -48,14 +90,14 @@ var RenderTexture = new Class({
|
|||
this.texture = this.renderer.createTexture2D(0, gl.NEAREST, gl.NEAREST, gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE, gl.RGBA, null, width, height, false);
|
||||
this.framebuffer = this.renderer.createFramebuffer(width, height, this.texture, false);
|
||||
}
|
||||
else
|
||||
else if (this.renderer.type === CONST.CANVAS)
|
||||
{
|
||||
this.fill = RenderTextureCanvas.fill;
|
||||
this.clear = RenderTextureCanvas.clear;
|
||||
this.draw = RenderTextureCanvas.draw;
|
||||
this.drawFrame = RenderTextureCanvas.drawFrame;
|
||||
this.canvas = CanvasPool.create2D(null, width, height);
|
||||
this.context = this.canvas.getContext('2d');
|
||||
this.context = this.canvas.getContext('2d');
|
||||
}
|
||||
|
||||
this.setPosition(x, y);
|
||||
|
@ -63,15 +105,56 @@ var RenderTexture = new Class({
|
|||
this.initPipeline('TextureTintPipeline');
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.GameObjects.RenderTexture#destroy
|
||||
* @since 3.2.0
|
||||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
GameObject.destroy.call(this);
|
||||
if (this.renderer.type === Phaser.WEBGL)
|
||||
|
||||
if (this.renderer.type === CONST.WEBGL)
|
||||
{
|
||||
this.renderer.deleteTexture(this.texture);
|
||||
this.renderer.deleteFramebuffer(this.framebuffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills the Render Texture with the given color.
|
||||
*
|
||||
* @method Phaser.GameObjects.RenderTexture#fill
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param {number} rgb - The color to fill the Render Texture with.
|
||||
*
|
||||
* @return {Phaser.GameObjects.RenderTexture} This Game Object.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Clears the Render Texture.
|
||||
*
|
||||
* @method Phaser.GameObjects.RenderTexture#clear
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @return {Phaser.GameObjects.RenderTexture} This Game Object.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Draws a texture frame to the Render Texture at the given position.
|
||||
*
|
||||
* @method Phaser.GameObjects.RenderTexture#draw
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.
|
||||
* @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with.
|
||||
* @param {number} x - The x position to draw the frame at.
|
||||
* @param {number} y - The y position to draw the frame at.
|
||||
*
|
||||
* @return {Phaser.GameObjects.RenderTexture} This Game Object.
|
||||
*/
|
||||
|
||||
});
|
||||
|
||||
|
|
|
@ -1,5 +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 GameObject = require('../GameObject');
|
||||
|
||||
/**
|
||||
* Renders this Game Object with the Canvas Renderer to the given Camera.
|
||||
* The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera.
|
||||
* This method should not be called directly. It is a utility function of the Render module.
|
||||
*
|
||||
* @method Phaser.GameObjects.RenderTexture#renderCanvas
|
||||
* @since 3.2.0
|
||||
* @private
|
||||
*
|
||||
* @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer.
|
||||
* @param {Phaser.GameObjects.RenderTexture} renderTexture - The Game Object being rendered in this call.
|
||||
* @param {number} interpolationPercentage - Reserved for future use and custom pipelines.
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
|
||||
*/
|
||||
var RenderTextureCanvasRenderer = function (renderer, renderTexture, interpolationPercentage, camera)
|
||||
{
|
||||
if (GameObject.RENDER_MASK !== renderTexture.renderFlags || (renderTexture.cameraFilter > 0 && (renderTexture.cameraFilter & camera._id)))
|
||||
|
@ -45,7 +65,7 @@ var RenderTextureCanvasRenderer = function (renderer, renderTexture, interpolati
|
|||
if (renderTexture.flipY)
|
||||
{
|
||||
fy = -1;
|
||||
dy -= renderTexture.canvas.height - src.displayOriginY;
|
||||
dy -= renderTexture.canvas.height - renderTexture.displayOriginY;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -59,7 +79,6 @@ var RenderTextureCanvasRenderer = function (renderer, renderTexture, interpolati
|
|||
ctx.scale(fx, fy);
|
||||
ctx.drawImage(renderTexture.canvas, dx, dy);
|
||||
ctx.restore();
|
||||
|
||||
};
|
||||
|
||||
module.exports = RenderTextureCanvasRenderer;
|
||||
|
|
|
@ -1,9 +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 BuildGameObject = require('../BuildGameObject');
|
||||
var BuildGameObjectAnimation = require('../BuildGameObjectAnimation');
|
||||
var GameObjectCreator = require('../GameObjectCreator');
|
||||
var GetAdvancedValue = require('../../utils/object/GetAdvancedValue');
|
||||
var RenderTexture = require('./RenderTexture');
|
||||
|
||||
/**
|
||||
* Creates a new Render Texture Game Object and returns it.
|
||||
*
|
||||
* Note: This method will only be available if the Render Texture Game Object has been built into Phaser.
|
||||
*
|
||||
* @method Phaser.GameObjects.GameObjectCreator#renderTexture
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param {object} config - [description]
|
||||
*
|
||||
* @return {Phaser.GameObjects.RenderTexture} The Game Object that was created.
|
||||
*/
|
||||
GameObjectCreator.register('renderTexture', function (config)
|
||||
{
|
||||
var x = GetAdvancedValue(config, 'x', 0);
|
||||
|
|
|
@ -1,6 +1,27 @@
|
|||
/**
|
||||
* @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 GameObjectFactory = require('../GameObjectFactory');
|
||||
var RenderTexture = require('./RenderTexture');
|
||||
|
||||
/**
|
||||
* Creates a new Render Texture Game Object and adds it to the Scene.
|
||||
*
|
||||
* Note: This method will only be available if the Render Texture Game Object has been built into Phaser.
|
||||
*
|
||||
* @method Phaser.GameObjects.GameObjectFactory#renderTexture
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param {number} x - The horizontal position of this Game Object in the world.
|
||||
* @param {number} y - The vertical position of this Game Object in the world.
|
||||
* @param {integer} [width=32] - The width of the Render Texture.
|
||||
* @param {integer} [height=32] - The height of the Render Texture.
|
||||
*
|
||||
* @return {Phaser.GameObjects.RenderTexture} The Game Object that was created.
|
||||
*/
|
||||
GameObjectFactory.register('renderTexture', function (x, y, width, height)
|
||||
{
|
||||
return this.displayList.add(new RenderTexture(this.scene, x, y, width, height));
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
/**
|
||||
* @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('../../utils/NOOP');
|
||||
var renderCanvas = require('../../utils/NOOP');
|
||||
|
||||
|
|
|
@ -1,5 +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 GameObject = require('../GameObject');
|
||||
|
||||
/**
|
||||
* Renders this Game Object with the Canvas Renderer to the given Camera.
|
||||
* The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera.
|
||||
* This method should not be called directly. It is a utility function of the Render module.
|
||||
*
|
||||
* @method Phaser.GameObjects.RenderTexture#renderWebgl
|
||||
* @since 3.2.0
|
||||
* @private
|
||||
*
|
||||
* @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active Canvas renderer.
|
||||
* @param {Phaser.GameObjects.RenderTexture} renderTexture - The Game Object being rendered in this call.
|
||||
* @param {number} interpolationPercentage - Reserved for future use and custom pipelines.
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
|
||||
*/
|
||||
var RenderTextureWebGLRenderer = function (renderer, renderTexture, interpolationPercentage, camera)
|
||||
{
|
||||
if (GameObject.RENDER_MASK !== renderTexture.renderFlags || (renderTexture.cameraFilter > 0 && (renderTexture.cameraFilter & camera._id)))
|
||||
|
@ -20,7 +40,7 @@ var RenderTextureWebGLRenderer = function (renderer, renderTexture, interpolatio
|
|||
renderTexture.displayOriginX, renderTexture.displayOriginY,
|
||||
0, 0, renderTexture.texture.width, renderTexture.texture.height,
|
||||
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
|
||||
0, 0,
|
||||
0, 0,
|
||||
camera
|
||||
);
|
||||
};
|
||||
|
|
|
@ -117,7 +117,7 @@ var Sprite = new Class({
|
|||
* @param {boolean} ignoreIfPlaying - [description]
|
||||
* @param {integer|string} startFrame - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
* @return {Phaser.GameObjects.Sprite} This Game Object.
|
||||
*/
|
||||
play: function (key, ignoreIfPlaying, startFrame)
|
||||
{
|
||||
|
|
|
@ -196,7 +196,7 @@ var TileSprite = new Class({
|
|||
*/
|
||||
updateTileTexture: function ()
|
||||
{
|
||||
if (!this.dirty && this.oldFrame == this.frame)
|
||||
if (!this.dirty && this.oldFrame === this.frame)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -204,6 +204,7 @@ var TileSprite = new Class({
|
|||
this.oldFrame = this.frame;
|
||||
|
||||
this.canvasBufferCtx.clearRect(0, 0, this.canvasBuffer.width, this.canvasBuffer.height);
|
||||
|
||||
this.canvasBufferCtx.drawImage(
|
||||
this.frame.source.image,
|
||||
this.frame.cutX, this.frame.cutY,
|
||||
|
|
|
@ -248,11 +248,9 @@ var Zone = new Class({
|
|||
this.setRectangleDropZone(this.width, this.height);
|
||||
}
|
||||
else
|
||||
if (!this.input)
|
||||
{
|
||||
if (!this.input)
|
||||
{
|
||||
this.setInteractive(shape, callback, true);
|
||||
}
|
||||
this.setInteractive(shape, callback, true);
|
||||
}
|
||||
|
||||
return this;
|
||||
|
|
|
@ -529,7 +529,6 @@ var InputPlugin = new Class({
|
|||
}
|
||||
|
||||
var i;
|
||||
var c;
|
||||
var gameObject;
|
||||
var list;
|
||||
var input;
|
||||
|
|
|
@ -362,13 +362,13 @@ var KeyboardManager = new Class({
|
|||
var event = queue[i];
|
||||
var code = event.keyCode;
|
||||
|
||||
// Will emit a keyboard or keyup event
|
||||
this.emit(event.type, event);
|
||||
|
||||
if (event.type === 'keydown')
|
||||
{
|
||||
if (KeyMap[code])
|
||||
if (KeyMap[code] && (keys[code] === undefined || keys[code].isDown === false))
|
||||
{
|
||||
// Will emit a keyboard or keyup event
|
||||
this.emit(event.type, event);
|
||||
|
||||
this.emit('keydown_' + KeyMap[code], event);
|
||||
}
|
||||
|
||||
|
@ -379,6 +379,9 @@ var KeyboardManager = new Class({
|
|||
}
|
||||
else
|
||||
{
|
||||
// Will emit a keyboard or keyup event
|
||||
this.emit(event.type, event);
|
||||
|
||||
this.emit('keyup_' + KeyMap[code], event);
|
||||
|
||||
if (keys[code])
|
||||
|
|
|
@ -34,10 +34,14 @@ var ProcessKeyDown = function (key, event)
|
|||
key.shiftKey = event.shiftKey;
|
||||
key.location = event.location;
|
||||
|
||||
key.isDown = true;
|
||||
key.isUp = false;
|
||||
key.timeDown = event.timeStamp;
|
||||
key.duration = 0;
|
||||
if (key.isDown === false)
|
||||
{
|
||||
key.isDown = true;
|
||||
key.isUp = false;
|
||||
key.timeDown = event.timeStamp;
|
||||
key.duration = 0;
|
||||
}
|
||||
|
||||
key.repeats++;
|
||||
|
||||
key._justDown = true;
|
||||
|
|
|
@ -118,7 +118,7 @@ var File = new Class({
|
|||
* @type {integer}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.state = typeof(this.url) === "function" ? CONST.FILE_POPULATED : CONST.FILE_PENDING;
|
||||
this.state = typeof(this.url) === 'function' ? CONST.FILE_POPULATED : CONST.FILE_PENDING;
|
||||
|
||||
/**
|
||||
* The total size of this file.
|
||||
|
|
|
@ -656,7 +656,7 @@ var LoaderPlugin = new Class({
|
|||
// Yup, add them to the Texture Manager
|
||||
|
||||
// Is the data JSON Hash or JSON Array?
|
||||
if (Array.isArray(data[0].frames))
|
||||
if (Array.isArray(data[0].textures) || Array.isArray(data[0].frames))
|
||||
{
|
||||
textures.addAtlasJSONArray(key, images, data);
|
||||
}
|
||||
|
|
48
src/math/interpolation/QuadraticBezierInterpolation.js
Normal file
48
src/math/interpolation/QuadraticBezierInterpolation.js
Normal file
|
@ -0,0 +1,48 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
function P0 (t, p)
|
||||
{
|
||||
var k = 1 - t;
|
||||
|
||||
return k * k * p;
|
||||
}
|
||||
|
||||
function P1 (t, p)
|
||||
{
|
||||
return 2 * (1 - t) * t * p;
|
||||
}
|
||||
|
||||
function P2 (t, p)
|
||||
{
|
||||
return t * t * p;
|
||||
}
|
||||
|
||||
// p0 = start point
|
||||
// p1 = control point 1
|
||||
// p2 = end point
|
||||
|
||||
// https://github.com/mrdoob/three.js/blob/master/src/extras/core/Interpolations.js
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Math.Interpolation.QuadraticBezier
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param {float} t - [description]
|
||||
* @param {number} p0 - [description]
|
||||
* @param {number} p1 - [description]
|
||||
* @param {number} p2 - [description]
|
||||
*
|
||||
* @return {number} [description]
|
||||
*/
|
||||
var QuadraticBezierInterpolation = function (t, p0, p1, p2)
|
||||
{
|
||||
return P0(t, p0) + P1(t, p1) + P2(t, p2);
|
||||
};
|
||||
|
||||
module.exports = QuadraticBezierInterpolation;
|
|
@ -9,10 +9,9 @@
|
|||
*/
|
||||
|
||||
module.exports = {
|
||||
|
||||
Bezier: require('./BezierInterpolation'),
|
||||
CatmullRom: require('./CatmullRomInterpolation'),
|
||||
CubicBezier: require('./CubicBezierInterpolation'),
|
||||
Linear: require('./LinearInterpolation')
|
||||
|
||||
Linear: require('./LinearInterpolation'),
|
||||
QuadraticBezier: require('./QuadraticBezierInterpolation')
|
||||
};
|
||||
|
|
|
@ -67,6 +67,17 @@ var RandomDataGenerator = new Class({
|
|||
*/
|
||||
this.s2 = 0;
|
||||
|
||||
/**
|
||||
* Internal var.
|
||||
*
|
||||
* @name Phaser.Math.RandomDataGenerator#n
|
||||
* @type {number}
|
||||
* @default 0
|
||||
* @private
|
||||
* @since 3.2.0
|
||||
*/
|
||||
this.n = 0;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
|
@ -74,7 +85,7 @@ var RandomDataGenerator = new Class({
|
|||
* @type {array}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.sign = [ -1, 1 ];
|
||||
this.signs = [ -1, 1 ];
|
||||
|
||||
if (seeds)
|
||||
{
|
||||
|
@ -117,7 +128,7 @@ var RandomDataGenerator = new Class({
|
|||
hash: function (data)
|
||||
{
|
||||
var h;
|
||||
var n = 0xefc8249d;
|
||||
var n = this.n;
|
||||
|
||||
data = data.toString();
|
||||
|
||||
|
@ -133,6 +144,8 @@ var RandomDataGenerator = new Class({
|
|||
n += h * 0x100000000;// 2^32
|
||||
}
|
||||
|
||||
this.n = n;
|
||||
|
||||
return (n >>> 0) * 2.3283064365386963e-10;// 2^-32
|
||||
},
|
||||
|
||||
|
@ -158,7 +171,7 @@ var RandomDataGenerator = new Class({
|
|||
|
||||
/**
|
||||
* Reset the seed of the random data generator.
|
||||
*
|
||||
*
|
||||
* _Note_: the seed array is only processed up to the first `undefined` (or `null`) value, should such be present.
|
||||
*
|
||||
* @method Phaser.Math.RandomDataGenerator#sow
|
||||
|
@ -169,9 +182,10 @@ var RandomDataGenerator = new Class({
|
|||
sow: function (seeds)
|
||||
{
|
||||
// Always reset to default seed
|
||||
this.n = 0xefc8249d;
|
||||
this.s0 = this.hash(' ');
|
||||
this.s1 = this.hash(this.s0);
|
||||
this.s2 = this.hash(this.s1);
|
||||
this.s1 = this.hash(' ');
|
||||
this.s2 = this.hash(' ');
|
||||
this.c = 1;
|
||||
|
||||
if (!seeds)
|
||||
|
@ -342,7 +356,7 @@ var RandomDataGenerator = new Class({
|
|||
*/
|
||||
sign: function ()
|
||||
{
|
||||
return this.pick(this.sign);
|
||||
return this.pick(this.signs);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -1364,10 +1364,11 @@ var World = new Class({
|
|||
*/
|
||||
collideHandler: function (object1, object2, collideCallback, processCallback, callbackContext, overlapOnly)
|
||||
{
|
||||
// Collide Group with Self
|
||||
// Only collide valid objects
|
||||
if (object2 === undefined && object1.isParent)
|
||||
{
|
||||
return this.collideGroupVsSelf(object1, collideCallback, processCallback, callbackContext, overlapOnly);
|
||||
return this.collideGroupVsGroup(object1, object1, collideCallback, processCallback, callbackContext, overlapOnly);
|
||||
}
|
||||
|
||||
// If neither of the objects are set then bail out
|
||||
|
|
|
@ -1483,7 +1483,7 @@ var WebGLRenderer = new Class({
|
|||
*
|
||||
* @return {WebGLTexture} [description]
|
||||
*/
|
||||
canvasToTexture: function (srcCanvas, dstTexture, shouldReallocate)
|
||||
canvasToTexture: function (srcCanvas, dstTexture)
|
||||
{
|
||||
var gl = this.gl;
|
||||
|
||||
|
@ -1502,11 +1502,11 @@ var WebGLRenderer = new Class({
|
|||
{
|
||||
this.setTexture2D(dstTexture, 0);
|
||||
|
||||
//if (!shouldReallocate && dstTexture.width >= srcCanvas.width || dstTexture.height >= srcCanvas.height)
|
||||
//{
|
||||
// if (!shouldReallocate && dstTexture.width >= srcCanvas.width || dstTexture.height >= srcCanvas.height)
|
||||
// {
|
||||
// gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, srcCanvas.width, srcCanvas.height, gl.RGBA, gl.UNSIGNED_BYTE, srcCanvas);
|
||||
//}
|
||||
//else
|
||||
// }
|
||||
// else
|
||||
{
|
||||
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, srcCanvas);
|
||||
dstTexture.width = srcCanvas.width;
|
||||
|
|
|
@ -119,10 +119,74 @@ var SceneManager = new Class({
|
|||
}
|
||||
|
||||
// Only need to wait for the boot event if we've scenes to actually boot
|
||||
game.events.once('ready', this.processQueue, this);
|
||||
game.events.once('ready', this.bootQueue, this);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Internal first-time Scene boot handler.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#bootQueue
|
||||
* @since 3.2.0
|
||||
*/
|
||||
bootQueue: function ()
|
||||
{
|
||||
var i;
|
||||
var entry;
|
||||
var key;
|
||||
var sceneConfig;
|
||||
|
||||
for (i = 0; i < this._pending.length; i++)
|
||||
{
|
||||
entry = this._pending[i];
|
||||
|
||||
key = entry.key;
|
||||
sceneConfig = entry.scene;
|
||||
|
||||
var newScene;
|
||||
|
||||
if (sceneConfig instanceof Scene)
|
||||
{
|
||||
newScene = this.createSceneFromInstance(key, sceneConfig);
|
||||
}
|
||||
else if (typeof sceneConfig === 'object')
|
||||
{
|
||||
sceneConfig.key = key;
|
||||
|
||||
newScene = this.createSceneFromObject(key, sceneConfig);
|
||||
}
|
||||
else if (typeof sceneConfig === 'function')
|
||||
{
|
||||
newScene = this.createSceneFromFunction(key, sceneConfig);
|
||||
}
|
||||
|
||||
// Replace key in case the scene changed it
|
||||
key = newScene.sys.settings.key;
|
||||
|
||||
this.keys[key] = newScene;
|
||||
|
||||
this.scenes.push(newScene);
|
||||
|
||||
if (entry.autoStart || newScene.sys.settings.active)
|
||||
{
|
||||
this._start.push(key);
|
||||
}
|
||||
}
|
||||
|
||||
// Clear the pending lists
|
||||
this._pending.length = 0;
|
||||
|
||||
// _start might have been populated by the above
|
||||
for (i = 0; i < this._start.length; i++)
|
||||
{
|
||||
entry = this._start[i];
|
||||
|
||||
this.start(entry);
|
||||
}
|
||||
|
||||
this._start.length = 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
|
@ -452,7 +516,7 @@ var SceneManager = new Class({
|
|||
{
|
||||
var sys = this.scenes[i].sys;
|
||||
|
||||
if (sys.settings.visible)
|
||||
if (sys.settings.visible && (sys.settings.status === CONST.RUNNING || sys.settings.status === CONST.PAUSED))
|
||||
{
|
||||
sys.render(renderer);
|
||||
}
|
||||
|
@ -1024,7 +1088,7 @@ var SceneManager = new Class({
|
|||
* @method Phaser.Scenes.SceneManager#bringToTop
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string|Phaser.Scene} scene - [description]
|
||||
* @param {string|Phaser.Scene} key - [description]
|
||||
*
|
||||
* @return {Phaser.Scenes.SceneManager} [description]
|
||||
*/
|
||||
|
@ -1056,7 +1120,7 @@ var SceneManager = new Class({
|
|||
* @method Phaser.Scenes.SceneManager#sendToBack
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string|Phaser.Scene} scene - [description]
|
||||
* @param {string|Phaser.Scene} key - [description]
|
||||
*
|
||||
* @return {Phaser.Scenes.SceneManager} [description]
|
||||
*/
|
||||
|
@ -1088,7 +1152,7 @@ var SceneManager = new Class({
|
|||
* @method Phaser.Scenes.SceneManager#moveDown
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string|Phaser.Scene} scene - [description]
|
||||
* @param {string|Phaser.Scene} key - [description]
|
||||
*
|
||||
* @return {Phaser.Scenes.SceneManager} [description]
|
||||
*/
|
||||
|
@ -1122,7 +1186,7 @@ var SceneManager = new Class({
|
|||
* @method Phaser.Scenes.SceneManager#moveUp
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string|Phaser.Scene} scene - [description]
|
||||
* @param {string|Phaser.Scene} key - [description]
|
||||
*
|
||||
* @return {Phaser.Scenes.SceneManager} [description]
|
||||
*/
|
||||
|
@ -1150,6 +1214,92 @@ var SceneManager = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Moves a Scene so it is immediately above another Scene in the Scenes list.
|
||||
* This means it will render over the top of the other Scene.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#moveAbove
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param {string|Phaser.Scene} keyA - The Scene that Scene B will be moved above.
|
||||
* @param {string|Phaser.Scene} keyB - The Scene to be moved.
|
||||
*
|
||||
* @return {Phaser.Scenes.SceneManager} [description]
|
||||
*/
|
||||
moveAbove: function (keyA, keyB)
|
||||
{
|
||||
if (keyA === keyB)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this._processing)
|
||||
{
|
||||
this._queue.push({ op: 'moveAbove', keyA: keyA, keyB: keyB });
|
||||
}
|
||||
else
|
||||
{
|
||||
var indexA = this.getIndex(keyA);
|
||||
var indexB = this.getIndex(keyB);
|
||||
|
||||
if (indexA > indexB && indexA !== -1 && indexB !== -1)
|
||||
{
|
||||
var tempScene = this.getAt(indexB);
|
||||
|
||||
// Remove
|
||||
this.scenes.splice(indexB, 1);
|
||||
|
||||
// Add in new location
|
||||
this.scenes.splice(indexA, 0, tempScene);
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Moves a Scene so it is immediately below another Scene in the Scenes list.
|
||||
* This means it will render behind the other Scene.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#moveBelow
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param {string|Phaser.Scene} keyA - The Scene that Scene B will be moved above.
|
||||
* @param {string|Phaser.Scene} keyB - The Scene to be moved.
|
||||
*
|
||||
* @return {Phaser.Scenes.SceneManager} [description]
|
||||
*/
|
||||
moveBelow: function (keyA, keyB)
|
||||
{
|
||||
if (keyA === keyB)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this._processing)
|
||||
{
|
||||
this._queue.push({ op: 'moveBelow', keyA: keyA, keyB: keyB });
|
||||
}
|
||||
else
|
||||
{
|
||||
var indexA = this.getIndex(keyA);
|
||||
var indexB = this.getIndex(keyB);
|
||||
|
||||
if (indexA < indexB && indexA !== -1 && indexB !== -1)
|
||||
{
|
||||
var tempScene = this.getAt(indexB);
|
||||
|
||||
// Remove
|
||||
this.scenes.splice(indexB, 1);
|
||||
|
||||
// Add in new location
|
||||
this.scenes.splice(indexA, 0, tempScene);
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
queueOp: function (op, keyA, keyB)
|
||||
{
|
||||
this._queue.push({ op: op, keyA: keyA, keyB: keyB });
|
||||
|
@ -1196,6 +1346,24 @@ var SceneManager = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
dump: function ()
|
||||
{
|
||||
var out = [];
|
||||
var map = [ 'pending', 'init', 'start', 'loading', 'creating', 'running', 'paused', 'sleeping', 'shutdown', 'destroyed' ];
|
||||
|
||||
for (var i = 0; i < this.scenes.length; i++)
|
||||
{
|
||||
var sys = this.scenes[i].sys;
|
||||
|
||||
var key = (sys.settings.visible && (sys.settings.status === CONST.RUNNING || sys.settings.status === CONST.PAUSED)) ? '[*] ' : '[-] ';
|
||||
key += sys.settings.key + ' (' + map[sys.settings.status] + ')';
|
||||
|
||||
out.push(key);
|
||||
}
|
||||
|
||||
console.log(out.join('\n'));
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
|
|
|
@ -377,20 +377,72 @@ var ScenePlugin = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Swaps the position of two scenes in the Scenes list.
|
||||
* This controls the order in which they are rendered and updated.
|
||||
*
|
||||
* @method Phaser.Scenes.ScenePlugin#swapPosition
|
||||
* @since 3.0.0
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {string} keyA - The first Scene to swap.
|
||||
* @param {string} [keyB] - The second Scene to swap. If none is given it defaults to this Scene.
|
||||
*
|
||||
* @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object.
|
||||
*/
|
||||
swapPosition: function (key)
|
||||
swapPosition: function (keyA, keyB)
|
||||
{
|
||||
if (key && key !== this.key)
|
||||
if (keyB === undefined) { keyB = this.key; }
|
||||
|
||||
if (keyA !== keyB)
|
||||
{
|
||||
this.manager.swapPosition(this.key, key);
|
||||
this.manager.swapPosition(keyA, keyB);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Swaps the position of two scenes in the Scenes list, so that Scene B is directly above Scene A.
|
||||
* This controls the order in which they are rendered and updated.
|
||||
*
|
||||
* @method Phaser.Scenes.ScenePlugin#moveAbove
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param {string} keyA - The Scene that Scene B will be moved to be above.
|
||||
* @param {string} [keyB] - The Scene to be moved. If none is given it defaults to this Scene.
|
||||
*
|
||||
* @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object.
|
||||
*/
|
||||
moveAbove: function (keyA, keyB)
|
||||
{
|
||||
if (keyB === undefined) { keyB = this.key; }
|
||||
|
||||
if (keyA !== keyB)
|
||||
{
|
||||
this.manager.moveAbove(keyA, keyB);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Swaps the position of two scenes in the Scenes list, so that Scene B is directly below Scene A.
|
||||
* This controls the order in which they are rendered and updated.
|
||||
*
|
||||
* @method Phaser.Scenes.ScenePlugin#moveBelow
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param {string} keyA - The Scene that Scene B will be moved to be below.
|
||||
* @param {string} [keyB] - The Scene to be moved. If none is given it defaults to this Scene.
|
||||
*
|
||||
* @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object.
|
||||
*/
|
||||
moveBelow: function (keyA, keyB)
|
||||
{
|
||||
if (keyB === undefined) { keyB = this.key; }
|
||||
|
||||
if (keyA !== keyB)
|
||||
{
|
||||
this.manager.moveBelow(keyA, keyB);
|
||||
}
|
||||
|
||||
return this;
|
||||
|
|
|
@ -3,8 +3,9 @@
|
|||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
var Class = require('../../utils/Class');
|
||||
|
||||
var BaseSoundManager = require('../BaseSoundManager');
|
||||
var Class = require('../../utils/Class');
|
||||
var HTML5AudioSound = require('./HTML5AudioSound');
|
||||
|
||||
/**
|
||||
|
@ -20,8 +21,12 @@ var HTML5AudioSound = require('./HTML5AudioSound');
|
|||
* @param {Phaser.Game} game - Reference to the current game instance.
|
||||
*/
|
||||
var HTML5AudioSoundManager = new Class({
|
||||
|
||||
Extends: BaseSoundManager,
|
||||
initialize: function HTML5AudioSoundManager (game)
|
||||
|
||||
initialize:
|
||||
|
||||
function HTML5AudioSoundManager (game)
|
||||
{
|
||||
/**
|
||||
* Flag indicating whether if there are no idle instances of HTML5 Audio tag,
|
||||
|
@ -77,6 +82,7 @@ var HTML5AudioSoundManager = new Class({
|
|||
* @since 3.0.0
|
||||
*/
|
||||
this.onBlurPausedSounds = [];
|
||||
|
||||
this.locked = 'ontouchstart' in window;
|
||||
|
||||
/**
|
||||
|
@ -115,6 +121,7 @@ var HTML5AudioSoundManager = new Class({
|
|||
* @since 3.0.0
|
||||
*/
|
||||
this._volume = 1;
|
||||
|
||||
BaseSoundManager.call(this, game);
|
||||
},
|
||||
|
||||
|
@ -132,7 +139,9 @@ var HTML5AudioSoundManager = new Class({
|
|||
add: function (key, config)
|
||||
{
|
||||
var sound = new HTML5AudioSound(this, key, config);
|
||||
|
||||
this.sounds.push(sound);
|
||||
|
||||
return sound;
|
||||
},
|
||||
|
||||
|
@ -147,21 +156,32 @@ var HTML5AudioSoundManager = new Class({
|
|||
unlock: function ()
|
||||
{
|
||||
var _this = this;
|
||||
|
||||
var moved = false;
|
||||
|
||||
var detectMove = function ()
|
||||
{
|
||||
moved = true;
|
||||
};
|
||||
|
||||
var unlock = function ()
|
||||
{
|
||||
if (!_this.game.cache.audio.entries.size)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (moved)
|
||||
{
|
||||
moved = false;
|
||||
return;
|
||||
}
|
||||
|
||||
document.body.removeEventListener('touchmove', detectMove);
|
||||
document.body.removeEventListener('touchend', unlock);
|
||||
|
||||
var allTags = [];
|
||||
|
||||
_this.game.cache.audio.entries.each(function (key, tags)
|
||||
{
|
||||
for (var i = 0; i < tags.length; i++)
|
||||
|
@ -170,25 +190,30 @@ var HTML5AudioSoundManager = new Class({
|
|||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
var lastTag = allTags[allTags.length - 1];
|
||||
|
||||
lastTag.oncanplaythrough = function ()
|
||||
{
|
||||
lastTag.oncanplaythrough = null;
|
||||
_this.unlocked = true;
|
||||
};
|
||||
|
||||
allTags.forEach(function (tag)
|
||||
{
|
||||
tag.load();
|
||||
});
|
||||
};
|
||||
|
||||
this.once('unlocked', function ()
|
||||
{
|
||||
_this.forEachActiveSound(function (sound)
|
||||
this.forEachActiveSound(function (sound)
|
||||
{
|
||||
sound.duration = sound.tags[0].duration;
|
||||
sound.totalDuration = sound.tags[0].duration;
|
||||
});
|
||||
_this.lockedActionsQueue.forEach(function (lockedAction)
|
||||
|
||||
this.lockedActionsQueue.forEach(function (lockedAction)
|
||||
{
|
||||
if (lockedAction.sound[lockedAction.prop].apply)
|
||||
{
|
||||
|
@ -199,9 +224,11 @@ var HTML5AudioSoundManager = new Class({
|
|||
lockedAction.sound[lockedAction.prop] = lockedAction.value;
|
||||
}
|
||||
});
|
||||
_this.lockedActionsQueue.length = 0;
|
||||
_this.lockedActionsQueue = null;
|
||||
});
|
||||
|
||||
this.lockedActionsQueue.length = 0;
|
||||
this.lockedActionsQueue = null;
|
||||
}, this);
|
||||
|
||||
document.body.addEventListener('touchmove', detectMove, false);
|
||||
document.body.addEventListener('touchend', unlock, false);
|
||||
},
|
||||
|
@ -240,6 +267,7 @@ var HTML5AudioSoundManager = new Class({
|
|||
{
|
||||
sound.onFocus();
|
||||
});
|
||||
|
||||
this.onBlurPausedSounds.length = 0;
|
||||
},
|
||||
|
||||
|
@ -253,6 +281,7 @@ var HTML5AudioSoundManager = new Class({
|
|||
destroy: function ()
|
||||
{
|
||||
BaseSoundManager.prototype.destroy.call(this);
|
||||
|
||||
this.onBlurPausedSounds.length = 0;
|
||||
this.onBlurPausedSounds = null;
|
||||
},
|
||||
|
@ -281,51 +310,79 @@ var HTML5AudioSoundManager = new Class({
|
|||
prop: prop,
|
||||
value: value
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(HTML5AudioSoundManager.prototype, 'mute', {
|
||||
get: function ()
|
||||
{
|
||||
return this._mute;
|
||||
},
|
||||
set: function (value)
|
||||
{
|
||||
this._mute = value;
|
||||
this.forEachActiveSound(function (sound)
|
||||
{
|
||||
sound.setMute();
|
||||
});
|
||||
|
||||
/**
|
||||
* @event Phaser.Sound.HTML5AudioSoundManager#mute
|
||||
* @param {Phaser.Sound.HTML5AudioSoundManager} soundManager - Reference to the sound manager that emitted event.
|
||||
* @param {boolean} value - An updated value of Phaser.Sound.HTML5AudioSoundManager#mute property.
|
||||
*/
|
||||
this.emit('mute', this, value);
|
||||
}
|
||||
});
|
||||
Object.defineProperty(HTML5AudioSoundManager.prototype, 'volume', {
|
||||
get: function ()
|
||||
{
|
||||
return this._volume;
|
||||
/**
|
||||
* @event Phaser.Sound.HTML5AudioSoundManager#MuteEvent
|
||||
* @param {Phaser.Sound.HTML5AudioSoundManager} soundManager - Reference to the sound manager that emitted event.
|
||||
* @param {boolean} value - An updated value of Phaser.Sound.HTML5AudioSoundManager#mute property.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @name Phaser.Sound.HTML5AudioSoundManager#mute
|
||||
* @type {boolean}
|
||||
* @fires Phaser.Sound.HTML5AudioSoundManager#MuteEvent
|
||||
* @since 3.0.0
|
||||
*/
|
||||
mute: {
|
||||
|
||||
get: function ()
|
||||
{
|
||||
return this._mute;
|
||||
},
|
||||
|
||||
set: function (value)
|
||||
{
|
||||
this._mute = value;
|
||||
|
||||
this.forEachActiveSound(function (sound)
|
||||
{
|
||||
sound.setMute();
|
||||
});
|
||||
|
||||
this.emit('mute', this, value);
|
||||
}
|
||||
|
||||
},
|
||||
set: function (value)
|
||||
{
|
||||
this._volume = value;
|
||||
this.forEachActiveSound(function (sound)
|
||||
{
|
||||
sound.setVolume();
|
||||
});
|
||||
|
||||
/**
|
||||
* @event Phaser.Sound.HTML5AudioSoundManager#volume
|
||||
* @param {Phaser.Sound.HTML5AudioSoundManager} soundManager - Reference to the sound manager that emitted event.
|
||||
* @param {number} value - An updated value of Phaser.Sound.HTML5AudioSoundManager#volume property.
|
||||
*/
|
||||
this.emit('volume', this, value);
|
||||
/**
|
||||
* @event Phaser.Sound.HTML5AudioSoundManager#VolumeEvent
|
||||
* @param {Phaser.Sound.HTML5AudioSoundManager} soundManager - Reference to the sound manager that emitted event.
|
||||
* @param {number} value - An updated value of Phaser.Sound.HTML5AudioSoundManager#volume property.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @name Phaser.Sound.HTML5AudioSoundManager#volume
|
||||
* @type {number}
|
||||
* @fires Phaser.Sound.HTML5AudioSoundManager#VolumeEvent
|
||||
* @since 3.0.0
|
||||
*/
|
||||
volume: {
|
||||
|
||||
get: function ()
|
||||
{
|
||||
return this._volume;
|
||||
},
|
||||
|
||||
set: function (value)
|
||||
{
|
||||
this._volume = value;
|
||||
|
||||
this.forEachActiveSound(function (sound)
|
||||
{
|
||||
sound.setVolume();
|
||||
});
|
||||
|
||||
this.emit('volume', this, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
module.exports = HTML5AudioSoundManager;
|
||||
|
|
|
@ -3,8 +3,9 @@
|
|||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
var Class = require('../../utils/Class');
|
||||
|
||||
var BaseSoundManager = require('../BaseSoundManager');
|
||||
var Class = require('../../utils/Class');
|
||||
var WebAudioSound = require('./WebAudioSound');
|
||||
|
||||
/**
|
||||
|
@ -21,8 +22,12 @@ var WebAudioSound = require('./WebAudioSound');
|
|||
* @param {Phaser.Game} game - Reference to the current game instance.
|
||||
*/
|
||||
var WebAudioSoundManager = new Class({
|
||||
|
||||
Extends: BaseSoundManager,
|
||||
initialize: function WebAudioSoundManager (game)
|
||||
|
||||
initialize:
|
||||
|
||||
function WebAudioSoundManager (game)
|
||||
{
|
||||
/**
|
||||
* The AudioContext being used for playback.
|
||||
|
@ -53,7 +58,9 @@ var WebAudioSoundManager = new Class({
|
|||
* @since 3.0.0
|
||||
*/
|
||||
this.masterVolumeNode = this.context.createGain();
|
||||
|
||||
this.masterMuteNode.connect(this.masterVolumeNode);
|
||||
|
||||
this.masterVolumeNode.connect(this.context.destination);
|
||||
|
||||
/**
|
||||
|
@ -65,7 +72,9 @@ var WebAudioSoundManager = new Class({
|
|||
* @since 3.0.0
|
||||
*/
|
||||
this.destination = this.masterMuteNode;
|
||||
|
||||
this.locked = this.context.state === 'suspended' && 'ontouchstart' in window;
|
||||
|
||||
BaseSoundManager.call(this, game);
|
||||
},
|
||||
|
||||
|
@ -87,11 +96,13 @@ var WebAudioSoundManager = new Class({
|
|||
createAudioContext: function (game)
|
||||
{
|
||||
var audioConfig = game.config.audio;
|
||||
|
||||
if (audioConfig && audioConfig.context)
|
||||
{
|
||||
audioConfig.context.resume();
|
||||
return audioConfig.context;
|
||||
}
|
||||
|
||||
return new AudioContext();
|
||||
},
|
||||
|
||||
|
@ -108,8 +119,11 @@ var WebAudioSoundManager = new Class({
|
|||
*/
|
||||
add: function (key, config)
|
||||
{
|
||||
|
||||
var sound = new WebAudioSound(this, key, config);
|
||||
|
||||
this.sounds.push(sound);
|
||||
|
||||
return sound;
|
||||
},
|
||||
|
||||
|
@ -125,6 +139,7 @@ var WebAudioSoundManager = new Class({
|
|||
unlock: function ()
|
||||
{
|
||||
var _this = this;
|
||||
|
||||
var unlock = function ()
|
||||
{
|
||||
_this.context.resume().then(function ()
|
||||
|
@ -134,6 +149,7 @@ var WebAudioSoundManager = new Class({
|
|||
_this.unlocked = true;
|
||||
});
|
||||
};
|
||||
|
||||
document.body.addEventListener('touchstart', unlock, false);
|
||||
document.body.addEventListener('touchend', unlock, false);
|
||||
},
|
||||
|
@ -178,6 +194,7 @@ var WebAudioSoundManager = new Class({
|
|||
this.masterVolumeNode = null;
|
||||
this.masterMuteNode.disconnect();
|
||||
this.masterMuteNode = null;
|
||||
|
||||
if (this.game.config.audio && this.game.config.audio.context)
|
||||
{
|
||||
this.context.suspend();
|
||||
|
@ -186,42 +203,68 @@ var WebAudioSoundManager = new Class({
|
|||
{
|
||||
this.context.close();
|
||||
}
|
||||
|
||||
this.context = null;
|
||||
|
||||
BaseSoundManager.prototype.destroy.call(this);
|
||||
}
|
||||
});
|
||||
Object.defineProperty(WebAudioSoundManager.prototype, 'mute', {
|
||||
get: function ()
|
||||
{
|
||||
return this.masterMuteNode.gain.value === 0;
|
||||
},
|
||||
set: function (value)
|
||||
{
|
||||
this.masterMuteNode.gain.setValueAtTime(value ? 0 : 1, 0);
|
||||
|
||||
/**
|
||||
* @event Phaser.Sound.WebAudioSoundManager#mute
|
||||
* @param {Phaser.Sound.WebAudioSoundManager} soundManager - Reference to the sound manager that emitted event.
|
||||
* @param {boolean} value - An updated value of Phaser.Sound.WebAudioSoundManager#mute property.
|
||||
*/
|
||||
this.emit('mute', this, value);
|
||||
}
|
||||
});
|
||||
Object.defineProperty(WebAudioSoundManager.prototype, 'volume', {
|
||||
get: function ()
|
||||
{
|
||||
return this.masterVolumeNode.gain.value;
|
||||
/**
|
||||
* @event Phaser.Sound.WebAudioSoundManager#MuteEvent
|
||||
* @param {Phaser.Sound.WebAudioSoundManager} soundManager - Reference to the sound manager that emitted event.
|
||||
* @param {boolean} value - An updated value of Phaser.Sound.WebAudioSoundManager#mute property.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @name Phaser.Sound.WebAudioSoundManager#mute
|
||||
* @type {boolean}
|
||||
* @fires Phaser.Sound.WebAudioSoundManager#MuteEvent
|
||||
* @since 3.0.0
|
||||
*/
|
||||
mute: {
|
||||
|
||||
get: function ()
|
||||
{
|
||||
return (this.masterMuteNode.gain.value === 0);
|
||||
},
|
||||
|
||||
set: function (value)
|
||||
{
|
||||
this.masterMuteNode.gain.setValueAtTime(value ? 0 : 1, 0);
|
||||
|
||||
this.emit('mute', this, value);
|
||||
}
|
||||
|
||||
},
|
||||
set: function (value)
|
||||
{
|
||||
this.masterVolumeNode.gain.setValueAtTime(value, 0);
|
||||
|
||||
/**
|
||||
* @event Phaser.Sound.WebAudioSoundManager#volume
|
||||
* @param {Phaser.Sound.WebAudioSoundManager} soundManager - Reference to the sound manager that emitted event.
|
||||
* @param {number} value - An updated value of Phaser.Sound.WebAudioSoundManager#volume property.
|
||||
*/
|
||||
this.emit('volume', this, value);
|
||||
/**
|
||||
* @event Phaser.Sound.WebAudioSoundManager#VolumeEvent
|
||||
* @param {Phaser.Sound.WebAudioSoundManager} soundManager - Reference to the sound manager that emitted event.
|
||||
* @param {number} value - An updated value of Phaser.Sound.WebAudioSoundManager#volume property.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @name Phaser.Sound.WebAudioSoundManager#volume
|
||||
* @type {number}
|
||||
* @fires Phaser.Sound.WebAudioSoundManager#VolumeEvent
|
||||
* @since 3.0.0
|
||||
*/
|
||||
volume: {
|
||||
|
||||
get: function ()
|
||||
{
|
||||
return this.masterVolumeNode.gain.value;
|
||||
},
|
||||
|
||||
set: function (value)
|
||||
{
|
||||
this.masterVolumeNode.gain.setValueAtTime(value, 0);
|
||||
|
||||
this.emit('volume', this, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
module.exports = WebAudioSoundManager;
|
||||
|
|
|
@ -314,9 +314,11 @@ var TextureManager = new Class({
|
|||
|
||||
if (Array.isArray(data))
|
||||
{
|
||||
for (var i = 0; i < data.length; i++)
|
||||
var singleAtlasFile = (data.length === 1); // multi-pack with one atlas file for all images
|
||||
for (var i = 0; i < texture.source.length; i++)
|
||||
{
|
||||
Parser.JSONArray(texture, i, data[i]);
|
||||
var atlasData = singleAtlasFile ? data[0] : data[i];
|
||||
Parser.JSONArray(texture, i, atlasData);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -34,7 +34,7 @@ var JSONArray = function (texture, sourceIndex, json)
|
|||
texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height);
|
||||
|
||||
// By this stage frames is a fully parsed array
|
||||
var frames = (Array.isArray(json.textures)) ? json.textures[0].frames : json.frames;
|
||||
var frames = (Array.isArray(json.textures)) ? json.textures[sourceIndex].frames : json.frames;
|
||||
|
||||
var newFrame;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue