@@ -239,21 +239,28 @@ Array SpriteFrames::_get_frames() const {
239
239
240
240
Array SpriteFrames::_get_animations () const {
241
241
Array anims;
242
- for (Map<StringName, Anim>::Element *E = animations.front (); E; E = E->next ()) {
242
+
243
+ List<StringName> sorted_names;
244
+ get_animation_list (&sorted_names);
245
+ sorted_names.sort_custom <StringName::AlphCompare>();
246
+
247
+ for (List<StringName>::Element *E = sorted_names.front (); E; E = E->next ()) {
248
+ const Anim &anim = animations[E->get ()];
243
249
Dictionary d;
244
- d[" name" ] = E->key ();
245
- d[" speed" ] = E-> get () .speed ;
246
- d[" loop" ] = E-> get () .loop ;
250
+ d[" name" ] = E->get ();
251
+ d[" speed" ] = anim .speed ;
252
+ d[" loop" ] = anim .loop ;
247
253
Array frames;
248
- for (int i = 0 ; i < E-> get () .frames .size (); i++) {
249
- frames.push_back (E-> get () .frames [i]);
254
+ for (int i = 0 ; i < anim .frames .size (); i++) {
255
+ frames.push_back (anim .frames [i]);
250
256
}
251
257
d[" frames" ] = frames;
252
258
anims.push_back (d);
253
259
}
254
260
255
261
return anims;
256
262
}
263
+
257
264
void SpriteFrames::_set_animations (const Array &p_animations) {
258
265
animations.clear ();
259
266
for (int i = 0 ; i < p_animations.size (); i++) {
@@ -302,12 +309,12 @@ void SpriteFrames::_bind_methods() {
302
309
ClassDB::bind_method (D_METHOD (" _set_frames" ), &SpriteFrames::_set_frames);
303
310
ClassDB::bind_method (D_METHOD (" _get_frames" ), &SpriteFrames::_get_frames);
304
311
305
- ADD_PROPERTY (PropertyInfo (Variant::ARRAY, " frames" , PROPERTY_HINT_NONE, " " , 0 ), " _set_frames" , " _get_frames" ); // compatibility
312
+ ADD_PROPERTY (PropertyInfo (Variant::ARRAY, " frames" , PROPERTY_HINT_NONE, " " , 0 ), " _set_frames" , " _get_frames" ); // Compatibility with Godot 2.1.
306
313
307
314
ClassDB::bind_method (D_METHOD (" _set_animations" ), &SpriteFrames::_set_animations);
308
315
ClassDB::bind_method (D_METHOD (" _get_animations" ), &SpriteFrames::_get_animations);
309
316
310
- ADD_PROPERTY (PropertyInfo (Variant::ARRAY, " animations" , PROPERTY_HINT_NONE, " " , PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), " _set_animations" , " _get_animations" ); // compatibility
317
+ ADD_PROPERTY (PropertyInfo (Variant::ARRAY, " animations" , PROPERTY_HINT_NONE, " " , PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), " _set_animations" , " _get_animations" );
311
318
}
312
319
313
320
SpriteFrames::SpriteFrames () {
0 commit comments