package X::GFXButton; use strict; my @butts; #----------------------------------------------------- INI -------------------------------------------------------- #Erzeugen sub new {    my ($class,@params) = @_;    my $self = {};    bless($self,$class);    #for(qw(ID APP X Y IMG IMGHV)){$self->{$_} = shift(@params);}    $self->{ID} = shift(@params);              &n bsp; #ID oder Name    $self->{APP} = shift(@params);              &n bsp; #SDL APP    $self->{X} = shift(@params);    $self->{Y} = shift(@params);    $self->{IMG} = shift(@params);              &n bsp;     #IMG normal    $self->{IMGHV} = shift(@params);              &n bsp; #IMG hover    $self->{IMG_click} = shift(@params);            #IMG click    $self->{DOSUB} = shift(@params);              &n bsp; #Button's sub    $self->{HV} = 0;              &nbs p;             #Hover state    $self->draw($self->{IMG});              &n bsp;     #Display    push(@butts, $self);    return($self); } #------------ Alle Elemente Prüfen -------------------- sub checkall {    my ($self, $mx, $my) = @_;    my $active_element = 0;    my $B_event_sub = 0;    for(@butts) {        if($_->check_button($mx,$my)){$active_element = $_;}    }     #Events bearbeiten....          if($active_element) {$B_event_sub = $active_element->{DOSUB};}              return ($active_element, $B_event_sub);              &n bsp;              &n bsp;  #Object and the sub } sub check_button {    my ($self, $mx, $my) = @_;    my $img = $self->{IMG};    #Hover - Effekt    if($mx > $self->{X} &&  $mx < ($self->{X}+ $img->width)  && $my > $self->{Y}    &&   $my < ($self->{Y}+ $img->height) )    {        if(not  $self->{HV}) {$self->{HV}=1; $self->draw($self->{IMGHV});}         return $self;    } else    {            if($self->{HV}) {$self->{HV}=0; $self->draw($self->{IMG});}    }    return 0; } sub button_click {    my $self = shift; $self->draw($self->{IMG_click}); } sub button_check{} sub button_hover{} #---------------------------------------------------------- CODE OK ---------------------------------------------------------- #Grafik darstellen sub draw {    my ($self, $img) = @_;    my $dest_rect = SDL::Rect->new(-height => $img->height(),-width  => $img->width(),-x=> $self->{X},-y => $self->{Y});    $img->blit( SDL::Rect->new(-height => $img->height(),-width  => $img->width(),-x => 0, -y  => 0), $self->{APP}, $dest_rect );    $self->{APP}->update( $dest_rect ); } #Parameter zurückgeben (mehrere) sub get {my ($self, @values) = @_; my @out = ();for(@values) {push(@out,$self->{"$_"}); } return @out;} #Einelnen Parameter setzen sub set {my ($self, $param, $value) = @_;  $self->{$param} = $value;} 1;