forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathToJSON.js
More file actions
55 lines (51 loc) · 1.41 KB
/
Copy pathToJSON.js
File metadata and controls
55 lines (51 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2019 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* Build a JSON representation of the given Game Object.
*
* This is typically extended further by Game Object specific implementations.
*
* @method Phaser.GameObjects.Components.ToJSON
* @since 3.0.0
*
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to export as JSON.
*
* @return {Phaser.Types.GameObjects.JSONGameObject} A JSON representation of the Game Object.
*/
var ToJSON = function (gameObject)
{
var out = {
name: gameObject.name,
type: gameObject.type,
x: gameObject.x,
y: gameObject.y,
depth: gameObject.depth,
scale: {
x: gameObject.scaleX,
y: gameObject.scaleY
},
origin: {
x: gameObject.originX,
y: gameObject.originY
},
flipX: gameObject.flipX,
flipY: gameObject.flipY,
rotation: gameObject.rotation,
alpha: gameObject.alpha,
visible: gameObject.visible,
blendMode: gameObject.blendMode,
textureKey: '',
frameKey: '',
data: {}
};
if (gameObject.texture)
{
out.textureKey = gameObject.texture.key;
out.frameKey = gameObject.frame.name;
}
return out;
};
module.exports = ToJSON;