Skip to content

Commit

Permalink
[feature] implement 'animation_completed' signal
Browse files Browse the repository at this point in the history
  • Loading branch information
jkb0o committed Mar 12, 2021
1 parent 3beb9a5 commit 657a9f8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions flash_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,19 @@ void FlashPlayer::_notification(int p_what) {
case NOTIFICATION_PROCESS: {
performance_triangles_generated = 0;
if (playing) {
bool animation_completed = false;
frame += get_process_delta_time()*frame_rate;
if (!loop && frame > playback_end)
if (!loop && frame > playback_end) {
animation_completed = true;
frame = playback_end - 0.0001;
else while (frame > playback_end)
} else while (frame > playback_end) {
animation_completed = true;
frame -= playback_end - playback_start;
}
batch();
if (animation_completed) {
emit_signal("animation_completed");
}
}
} break;

Expand Down Expand Up @@ -269,6 +276,7 @@ void FlashPlayer::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::STRING, "active_timeline", PROPERTY_HINT_ENUM, ""), "set_active_timeline", "get_active_timeline");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "active_label", PROPERTY_HINT_ENUM, ""), "set_active_label", "get_active_label");

ADD_SIGNAL(MethodInfo("animation_completed"));
}

float FlashPlayer::get_duration(String p_timeline, String p_label) {
Expand Down

0 comments on commit 657a9f8

Please sign in to comment.