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
47 lines (42 loc) · 1.17 KB
/
ToJSON.js
File metadata and controls
47 lines (42 loc) · 1.17 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
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
// Default Game Object JSON export
// Is extended further by Game Object specific implementations
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,
scaleMode: gameObject.scaleMode,
blendMode: gameObject.blendMode,
textureKey: '',
frameKey: '',
data: {}
};
if (gameObject.texture)
{
out.textureKey = gameObject.texture.key;
out.frameKey = gameObject.frame.name;
}
return out;
};
module.exports = ToJSON;