Changes to simplify LoadVirtualSprite
This commit is contained in:
parent
53075c961f
commit
c7136d010c
|
|
@ -181,32 +181,31 @@ sub LoadVirtualSprite {
|
||||||
return $files{$name};
|
return $files{$name};
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (@files) {
|
my @frames = map { GetAsset($_) || return } (@files);
|
||||||
if(!LoadAsset($_)) {
|
my $h = $frames[0]->surface()->height();
|
||||||
LogData(ERROR, "Unable to load virtual sprite, error loading one or more assets.");
|
|
||||||
return undef;
|
|
||||||
}
|
|
||||||
LogData(DEBUG, "Adding asset $_ to virtual sprite $name");
|
|
||||||
}
|
|
||||||
|
|
||||||
my @frames = map { $files{$_}{'Sprite'}->surface() } (@files);
|
|
||||||
my $h = $frames[0]->height();
|
|
||||||
my $hp = 0;
|
my $hp = 0;
|
||||||
|
|
||||||
my $newsurface = SDLx::Surface->new( width => $frames[0]->width(),
|
LogData(INFO, sprintf("Format = '%s', Pitch = '%s'",
|
||||||
|
$frames[0]->surface()->format(),
|
||||||
|
));
|
||||||
|
exit(0);
|
||||||
|
|
||||||
|
my $newsurface = SDLx::Surface->new( width => $frames[0]->surface()->width(),
|
||||||
height => $h * (@frames-0),
|
height => $h * (@frames-0),
|
||||||
format => $frames[0]->format(),
|
format => $frames[0]->surface()->format(),
|
||||||
pitch => $frames[0]->pitch(),
|
pitch => $frames[0]->surface()->pitch(),
|
||||||
flags => $frames[0]->flags(),
|
flags => $frames[0]->surface()->flags(),
|
||||||
|
color => [0, 0, 0, 255],
|
||||||
);
|
);
|
||||||
$newsurface->draw_rect( [0, 0, $newsurface->width(), $newsurface->height()], [0, 0, 0, 255]);
|
|
||||||
#SDL::Video::set_alpha( $newsurface, SDL::Video::SDL_SRCALPHA, 0);
|
#SDL::Video::set_alpha($newsurface, SDL::Video::SDL_RLEACCEL, 0);
|
||||||
|
#my $f = SDL::Video::SDL_SRCALPHA | SDL::Video::SDL_RLEACCEL;
|
||||||
foreach (@frames) {
|
foreach (@frames) {
|
||||||
#SDL::Video::set_alpha( $_, SDL::Video::SDL_SRCALPHA, 255);
|
#SDL::Video::set_alpha( $_->surface(), $f, 0);
|
||||||
#FIXME - This call ignores the source alpha channel
|
$_->draw_xy($newsurface, 0, $hp);
|
||||||
$_->blit( $newsurface, undef, [0, $hp, $_->width(), $_->height()]);
|
|
||||||
$hp += $h;
|
$hp += $h;
|
||||||
}
|
}
|
||||||
|
#SDL::Video::set_alpha($newsurface, $f, 0);
|
||||||
|
|
||||||
my $anim = SDLx::Sprite::Animated->new( surface => $newsurface,
|
my $anim = SDLx::Sprite::Animated->new( surface => $newsurface,
|
||||||
width => $newsurface->width(),
|
width => $newsurface->width(),
|
||||||
|
|
@ -220,5 +219,4 @@ sub LoadVirtualSprite {
|
||||||
return $anim;
|
return $anim;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue