2828 * @extends ccs.Component
2929 */
3030ccs . ComAttribute = ccs . Component . extend ( /** @lends ccs.ComAttribute# */ {
31- _attributes : null ,
3231 _jsonDict : null ,
3332 _filePath : "" ,
3433 ctor : function ( ) {
3534 cc . Component . prototype . ctor . call ( this ) ;
36- this . _attributes = { } ;
3735 this . _jsonDict = { } ;
3836 this . _filePath = "" ;
3937 this . _name = "CCComAttribute" ;
4038 } ,
4139 init : function ( ) {
42- this . _attributes = { } ;
4340 this . _jsonDict = { } ;
4441 return true ;
4542 } ,
@@ -54,7 +51,7 @@ ccs.ComAttribute = ccs.Component.extend(/** @lends ccs.ComAttribute# */{
5451 cc . log ( "Argument must be non-nil" ) ;
5552 return ;
5653 }
57- this . _attributes [ key ] = value ;
54+ this . _jsonDict [ key ] = value ;
5855 } ,
5956
6057 /**
@@ -67,7 +64,7 @@ ccs.ComAttribute = ccs.Component.extend(/** @lends ccs.ComAttribute# */{
6764 cc . log ( "Argument must be non-nil" ) ;
6865 return ;
6966 }
70- this . _attributes [ key ] = value ;
67+ this . _jsonDict [ key ] = value ;
7168 } ,
7269
7370 /**
@@ -80,7 +77,7 @@ ccs.ComAttribute = ccs.Component.extend(/** @lends ccs.ComAttribute# */{
8077 cc . log ( "Argument must be non-nil" ) ;
8178 return ;
8279 }
83- this . _attributes [ key ] = value ;
80+ this . _jsonDict [ key ] = value ;
8481 } ,
8582
8683 /**
@@ -93,7 +90,7 @@ ccs.ComAttribute = ccs.Component.extend(/** @lends ccs.ComAttribute# */{
9390 cc . log ( "Argument must be non-nil" ) ;
9491 return ;
9592 }
96- this . _attributes [ key ] = value ;
93+ this . _jsonDict [ key ] = value ;
9794 } ,
9895
9996 /**
@@ -106,7 +103,7 @@ ccs.ComAttribute = ccs.Component.extend(/** @lends ccs.ComAttribute# */{
106103 cc . log ( "Argument must be non-nil" ) ;
107104 return ;
108105 }
109- this . _attributes [ key ] = value ;
106+ this . _jsonDict [ key ] = value ;
110107 } ,
111108
112109 /**
@@ -119,7 +116,7 @@ ccs.ComAttribute = ccs.Component.extend(/** @lends ccs.ComAttribute# */{
119116 cc . log ( "Argument must be non-nil" ) ;
120117 return ;
121118 }
122- this . _attributes [ key ] = value ;
119+ this . _jsonDict [ key ] = value ;
123120 } ,
124121
125122 /**
@@ -128,7 +125,7 @@ ccs.ComAttribute = ccs.Component.extend(/** @lends ccs.ComAttribute# */{
128125 * @returns {Number }
129126 */
130127 getInt : function ( key ) {
131- var ret = this . _attributes [ key ] ;
128+ var ret = this . _jsonDict [ key ] ;
132129 return parseInt ( ret || 0 ) ;
133130 } ,
134131
@@ -138,7 +135,7 @@ ccs.ComAttribute = ccs.Component.extend(/** @lends ccs.ComAttribute# */{
138135 * @returns {Number }
139136 */
140137 getDouble : function ( key ) {
141- var ret = this . _attributes [ key ] ;
138+ var ret = this . _jsonDict [ key ] ;
142139 return parseFloat ( ret || 0.0 ) ;
143140 } ,
144141
@@ -148,7 +145,7 @@ ccs.ComAttribute = ccs.Component.extend(/** @lends ccs.ComAttribute# */{
148145 * @returns {Number }
149146 */
150147 getFloat : function ( key ) {
151- var ret = this . _attributes [ key ] ;
148+ var ret = this . _jsonDict [ key ] ;
152149 return parseFloat ( ret || 0.0 ) ;
153150 } ,
154151
@@ -158,7 +155,7 @@ ccs.ComAttribute = ccs.Component.extend(/** @lends ccs.ComAttribute# */{
158155 * @returns {Boolean }
159156 */
160157 getBool : function ( key ) {
161- var ret = this . _attributes [ key ] ;
158+ var ret = this . _jsonDict [ key ] ;
162159 return Boolean ( ret || false ) ;
163160 } ,
164161
@@ -168,7 +165,7 @@ ccs.ComAttribute = ccs.Component.extend(/** @lends ccs.ComAttribute# */{
168165 * @returns {String }
169166 */
170167 getCString : function ( key ) {
171- var ret = this . _attributes [ key ] ;
168+ var ret = this . _jsonDict [ key ] ;
172169 return ret || "" ;
173170 } ,
174171
@@ -178,37 +175,18 @@ ccs.ComAttribute = ccs.Component.extend(/** @lends ccs.ComAttribute# */{
178175 * @returns {Object }
179176 */
180177 getObject : function ( key ) {
181- return this . _attributes [ key ] ;
178+ return this . _jsonDict [ key ] ;
182179 } ,
183180
184181 /**
185- * Getter of jsonDict
182+ *
183+ * @param path
186184 */
187- getDict : function ( ) {
188- return this . _jsonDict ;
189- } ,
190-
191- /**
192- * setter of jsonDict
193- * @returns {Object }
194- */
195- setDict : function ( dict ) {
196- this . _jsonDict = dict ;
197- } ,
198-
199- /**
200- * Getter of jsonName
201- * @returns {String }
202- */
203- getFile :function ( ) {
204- return this . _filePath ;
205- } ,
206-
207- /**
208- * setter of fileName
209- */
210- setFile :function ( filePath ) {
211- this . _filePath = filePath ;
185+ parse :function ( path ) {
186+ var data = cc . FileUtils . getInstance ( ) . getTextFileData ( path ) ;
187+ if ( data ) {
188+ this . _jsonDict = JSON . parse ( data ) ;
189+ }
212190 }
213191} ) ;
214192/**
0 commit comments