Games-FrogJump

 view release on metacpan or  search on metacpan

lib/Games/FrogJump/Animation.pm  view on Meta::CPAN

sub snapshot_frame_count {
    my $self = shift;
    return int($self->frame_count / @{$self->snapshot});
}

sub end {
    my $self = shift;
    return $self->current_frame >= $self->frame_count ? 1 : 0;
}

sub update {
    my $self = shift;
    my $obj  = $self->obj;
    my $attr = $self->attr;
    my $snap_index = int($self->current_frame / $self->snapshot_frame_count);
    $obj->$attr($self->snapshot->[$snap_index]) if $snap_index < @{$self->snapshot};
    $self->current_frame($self->current_frame + 1);
}
1;



( run in 0.287 second using v1.01-cache-2.11-cpan-4d4bc49f3ae )