mirror of
https://github.com/photonstorm/phaser
synced 2025-01-14 14:14:01 +00:00
34 lines
694 B
JavaScript
34 lines
694 B
JavaScript
|
var Scene = require('../Scene');
|
||
|
|
||
|
// private
|
||
|
var GetKey = function (key, sceneConfig)
|
||
|
{
|
||
|
if (!key) { key = 'default'; }
|
||
|
|
||
|
if (typeof sceneConfig === 'function')
|
||
|
{
|
||
|
return key;
|
||
|
}
|
||
|
else if (sceneConfig instanceof Scene)
|
||
|
{
|
||
|
key = sceneConfig.sys.settings.key;
|
||
|
}
|
||
|
else if (typeof sceneConfig === 'object' && sceneConfig.hasOwnProperty('key'))
|
||
|
{
|
||
|
key = sceneConfig.key;
|
||
|
}
|
||
|
|
||
|
// By this point it's either 'default' or extracted from the Scene
|
||
|
|
||
|
if (this.keys.hasOwnProperty(key))
|
||
|
{
|
||
|
throw new Error('Cannot add a Scene with duplicate key: ' + key);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return key;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
module.exports = GetKey;
|