mirror of
https://github.com/photonstorm/phaser
synced 2025-02-16 22:18:29 +00:00
Phaser.Utils.String.UUID
will return an RFC4122 complaint UUID as a string. This is used internally to avoid cache key conflicts, but is exposed for your own use as well.
This commit is contained in:
parent
fc0dc13930
commit
8c842f67de
3 changed files with 30 additions and 1 deletions
|
@ -55,6 +55,7 @@ The process of managing scissors in the WebGLRenderer has been completely rewrit
|
|||
* If you set `window.FORCE_WEBGL` or `window.FORCE_CANVAS` in the window in which the Phaser game is loaded it will over-ride the renderer type setting in your game config, and force either WebGL or Canvas. This is handy for quickly testing the differences between renderers without having to do a new build each time.
|
||||
* `TextureSource.source` is a new property that contains the original source of the Texture image. It is cleared when the source is destroyed.
|
||||
* `TransformMatrix.copyToContext` is a new method that will copy the values from the Matrix to the given Canvas Rendering Context.
|
||||
* `Phaser.Utils.String.UUID` will return an RFC4122 complaint UUID as a string. This is used internally to avoid cache key conflicts, but is exposed for your own use as well.
|
||||
|
||||
### Updates
|
||||
|
||||
|
|
27
src/utils/string/UUID.js
Normal file
27
src/utils/string/UUID.js
Normal file
|
@ -0,0 +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}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates and returns an RFC4122 version 4 compliant UUID.
|
||||
*
|
||||
* The string is in the form: `xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx` where each `x` is replaced with a random
|
||||
* hexadecimal digit from 0 to f, and `y` is replaced with a random hexadecimal digit from 8 to b.
|
||||
*
|
||||
* @function Phaser.Utils.String.UUID
|
||||
* @since 3.12.0
|
||||
*
|
||||
* @return {string} The UUID string.
|
||||
*/
|
||||
var UUID = function ()
|
||||
{
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c)
|
||||
{
|
||||
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
|
||||
return v.toString(16);
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = UUID;
|
|
@ -13,6 +13,7 @@ module.exports = {
|
|||
Format: require('./Format'),
|
||||
Pad: require('./Pad'),
|
||||
Reverse: require('./Reverse'),
|
||||
UppercaseFirst: require('./UppercaseFirst')
|
||||
UppercaseFirst: require('./UppercaseFirst'),
|
||||
UUID: require('./UUID')
|
||||
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue