File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11var CHECKSUM = {
2- build : 'd62d2ed0-1f8b -11e7-b52d-db08b948d03e '
2+ build : 'dd446940-1fd6 -11e7-b0f6-9b5f5f41e111 '
33} ;
44module . exports = CHECKSUM ;
Original file line number Diff line number Diff line change @@ -6,11 +6,9 @@ var ToJSON = function (gameObject)
66 var out = {
77 name : gameObject . name ,
88 type : gameObject . type ,
9- position : {
10- x : gameObject . x ,
11- y : gameObject . y ,
12- z : gameObject . z
13- } ,
9+ x : gameObject . x ,
10+ y : gameObject . y ,
11+ z : gameObject . z ,
1412 scale : {
1513 x : gameObject . scaleX ,
1614 y : gameObject . scaleY
@@ -19,23 +17,22 @@ var ToJSON = function (gameObject)
1917 x : gameObject . originX ,
2018 y : gameObject . originY
2119 } ,
22- flip : {
23- x : gameObject . flipX ,
24- y : gameObject . flipY
25- } ,
20+ flipX : gameObject . flipX ,
21+ flipY : gameObject . flipY ,
2622 rotation : gameObject . rotation ,
2723 alpha : gameObject . alpha ,
2824 visible : gameObject . visible ,
2925 scaleMode : gameObject . scaleMode ,
3026 blendMode : gameObject . blendMode ,
3127 textureKey : '' ,
32- frameKey : ''
28+ frameKey : '' ,
29+ data : { }
3330 } ;
3431
3532 if ( gameObject . texture )
3633 {
3734 out . textureKey = gameObject . texture . key ;
38- out . frameKey = gameObject . frame . key ;
35+ out . frameKey = gameObject . frame . name ;
3936 }
4037
4138 return out ;
Original file line number Diff line number Diff line change 55*/
66
77var Class = require ( '../utils/Class' ) ;
8+ var Components = require ( '../components' ) ;
89
910/**
1011* This is the base Game Object class that you can use when creating your own extended Game Objects.
@@ -37,6 +38,12 @@ var GameObject = new Class({
3738 {
3839 } ,
3940
41+ // Can be overridden by custom Game Objects, but provides default export functionality
42+ toJSON : function ( )
43+ {
44+ return Components . ToJSON ( this ) ;
45+ } ,
46+
4047 destroy : function ( )
4148 {
4249 this . parent . remove ( this ) ;
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ var BitmapText = new Class({
3030
3131 GameObject . call ( this , state , 'BitmapText' ) ;
3232
33+ this . font = font ;
3334 this . fontData = this . state . sys . cache . bitmapFont . get ( font ) ;
3435
3536 this . text = text ;
@@ -76,6 +77,23 @@ var BitmapText = new Class({
7677 // global = the BitmapText, taking into account scale and world position
7778
7879 return GetBitmapTextSize ( this ) ;
80+ } ,
81+
82+ toJSON : function ( )
83+ {
84+ var out = Components . ToJSON ( this ) ;
85+
86+ // Extra data is added here
87+
88+ var data = {
89+ font : this . font ,
90+ text : this . text ,
91+ fontSize : this . fontSize
92+ } ;
93+
94+ out . data = data ;
95+
96+ return out ;
7997 }
8098
8199} ) ;
Original file line number Diff line number Diff line change @@ -45,6 +45,15 @@ var Sprite = new Class({
4545 play : function ( key , startFrame )
4646 {
4747 return this . anims . play ( key , startFrame ) ;
48+ } ,
49+
50+ toJSON : function ( )
51+ {
52+ var data = Components . ToJSON ( this ) ;
53+
54+ // Extra Sprite data is added here
55+
56+ return data ;
4857 }
4958
5059} ) ;
Original file line number Diff line number Diff line change @@ -265,6 +265,28 @@ var Text = new Class({
265265 this . dirty = true ;
266266
267267 return this ;
268+ } ,
269+
270+ toJSON : function ( )
271+ {
272+ var out = Components . ToJSON ( this ) ;
273+
274+ // Extra Text data is added here
275+ // TODO: TextStyle.toJSON
276+
277+ var data = {
278+ autoRound : this . autoRound ,
279+ text : this . text ,
280+ resolution : this . resolution ,
281+ padding : {
282+ x : this . padding . x ,
283+ y : this . padding . y
284+ }
285+ } ;
286+
287+ out . data = data ;
288+
289+ return out ;
268290 }
269291} ) ;
270292
You can’t perform that action at this time.
0 commit comments