Hi Leute,
wie kann man einfache Animationen (move) mit Canvas
implementieren?
Hier mal mein Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use Tk;
use strict;
use warnings;
sub new {
my $class = shift();
my $parent = shift();
my $self = {parent => $parent,
canvas => $parent->Canvas};
return bless($self, $class);
}
sub AddNote {
my $self = shift();
$self->{note} = $self->{canvas}->create('rectangle',10, 10, 100, 100);
}
sub move {
my $self = shift();
for (my $i = 0; $i < 10; $i++) {
for (my $j = 0; $j < 2; $j++) {
$self->{canvas}->move($self->{note}, $i, $j);
}
}
}
sub start {
my $self = shift();
$self->{canvas}->pack(-expand => 1, -fill => 'both');
$self->move();
}
1;