@@ -3923,6 +3923,9 @@ bool TileSetAtlasSource::_set(const StringName &p_name, const Variant &p_value)
3923
3923
} else if (components[1 ] == " animation_speed" ) {
3924
3924
set_tile_animation_speed (coords, p_value);
3925
3925
return true ;
3926
+ } else if (components[1 ] == " animation_mode" ) {
3927
+ set_tile_animation_mode (coords, VariantCaster<TileSetAtlasSource::TileAnimationMode>::cast (p_value));
3928
+ return true ;
3926
3929
} else if (components[1 ] == " animation_frames_count" ) {
3927
3930
set_tile_animation_frames_count (coords, p_value);
3928
3931
return true ;
@@ -3990,6 +3993,9 @@ bool TileSetAtlasSource::_get(const StringName &p_name, Variant &r_ret) const {
3990
3993
} else if (components[1 ] == " animation_speed" ) {
3991
3994
r_ret = get_tile_animation_speed (coords);
3992
3995
return true ;
3996
+ } else if (components[1 ] == " animation_mode" ) {
3997
+ r_ret = get_tile_animation_mode (coords);
3998
+ return true ;
3993
3999
} else if (components[1 ] == " animation_frames_count" ) {
3994
4000
r_ret = get_tile_animation_frames_count (coords);
3995
4001
return true ;
@@ -4065,6 +4071,13 @@ void TileSetAtlasSource::_get_property_list(List<PropertyInfo> *p_list) const {
4065
4071
}
4066
4072
tile_property_list.push_back (property_info);
4067
4073
4074
+ // animation_mode.
4075
+ property_info = PropertyInfo (Variant::INT, " animation_mode" , PROPERTY_HINT_NONE, " " , PROPERTY_USAGE_NO_EDITOR);
4076
+ if (E_tile.value .animation_mode == TILE_ANIMATION_MODE_DEFAULT) {
4077
+ property_info.usage ^= PROPERTY_USAGE_STORAGE;
4078
+ }
4079
+ tile_property_list.push_back (property_info);
4080
+
4068
4081
// animation_frames_count.
4069
4082
tile_property_list.push_back (PropertyInfo (Variant::INT, " animation_frames_count" , PROPERTY_HINT_NONE, " " , PROPERTY_USAGE_NONE));
4070
4083
@@ -4227,6 +4240,20 @@ real_t TileSetAtlasSource::get_tile_animation_speed(const Vector2i p_atlas_coord
4227
4240
return tiles[p_atlas_coords].animation_speed ;
4228
4241
}
4229
4242
4243
+ void TileSetAtlasSource::set_tile_animation_mode (const Vector2i p_atlas_coords, TileSetAtlasSource::TileAnimationMode p_mode) {
4244
+ ERR_FAIL_COND_MSG (!tiles.has (p_atlas_coords), vformat (" TileSetAtlasSource has no tile at %s." , Vector2i (p_atlas_coords)));
4245
+
4246
+ tiles[p_atlas_coords].animation_mode = p_mode;
4247
+
4248
+ emit_signal (SNAME (" changed" ));
4249
+ }
4250
+
4251
+ TileSetAtlasSource::TileAnimationMode TileSetAtlasSource::get_tile_animation_mode (const Vector2i p_atlas_coords) const {
4252
+ ERR_FAIL_COND_V_MSG (!tiles.has (p_atlas_coords), TILE_ANIMATION_MODE_DEFAULT, vformat (" TileSetAtlasSource has no tile at %s." , Vector2i (p_atlas_coords)));
4253
+
4254
+ return tiles[p_atlas_coords].animation_mode ;
4255
+ }
4256
+
4230
4257
void TileSetAtlasSource::set_tile_animation_frames_count (const Vector2i p_atlas_coords, int p_frames_count) {
4231
4258
ERR_FAIL_COND_MSG (!tiles.has (p_atlas_coords), vformat (" TileSetAtlasSource has no tile at %s." , Vector2i (p_atlas_coords)));
4232
4259
ERR_FAIL_COND (p_frames_count < 1 );
@@ -4552,6 +4579,8 @@ void TileSetAtlasSource::_bind_methods() {
4552
4579
ClassDB::bind_method (D_METHOD (" get_tile_animation_separation" , " atlas_coords" ), &TileSetAtlasSource::get_tile_animation_separation);
4553
4580
ClassDB::bind_method (D_METHOD (" set_tile_animation_speed" , " atlas_coords" , " speed" ), &TileSetAtlasSource::set_tile_animation_speed);
4554
4581
ClassDB::bind_method (D_METHOD (" get_tile_animation_speed" , " atlas_coords" ), &TileSetAtlasSource::get_tile_animation_speed);
4582
+ ClassDB::bind_method (D_METHOD (" set_tile_animation_mode" , " atlas_coords" , " mode" ), &TileSetAtlasSource::set_tile_animation_mode);
4583
+ ClassDB::bind_method (D_METHOD (" get_tile_animation_mode" , " atlas_coords" ), &TileSetAtlasSource::get_tile_animation_mode);
4555
4584
ClassDB::bind_method (D_METHOD (" set_tile_animation_frames_count" , " atlas_coords" , " frames_count" ), &TileSetAtlasSource::set_tile_animation_frames_count);
4556
4585
ClassDB::bind_method (D_METHOD (" get_tile_animation_frames_count" , " atlas_coords" ), &TileSetAtlasSource::get_tile_animation_frames_count);
4557
4586
ClassDB::bind_method (D_METHOD (" set_tile_animation_frame_duration" , " atlas_coords" , " frame_index" , " duration" ), &TileSetAtlasSource::set_tile_animation_frame_duration);
@@ -4574,6 +4603,10 @@ void TileSetAtlasSource::_bind_methods() {
4574
4603
ClassDB::bind_method (D_METHOD (" _update_padded_texture" ), &TileSetAtlasSource::_update_padded_texture);
4575
4604
ClassDB::bind_method (D_METHOD (" get_runtime_texture" ), &TileSetAtlasSource::get_runtime_texture);
4576
4605
ClassDB::bind_method (D_METHOD (" get_runtime_tile_texture_region" , " atlas_coords" , " frame" ), &TileSetAtlasSource::get_runtime_tile_texture_region);
4606
+
4607
+ BIND_ENUM_CONSTANT (TILE_ANIMATION_MODE_DEFAULT)
4608
+ BIND_ENUM_CONSTANT (TILE_ANIMATION_MODE_RANDOM_START_TIMES)
4609
+ BIND_ENUM_CONSTANT (TILE_ANIMATION_MODE_MAX)
4577
4610
}
4578
4611
4579
4612
TileSetAtlasSource::~TileSetAtlasSource () {
0 commit comments