NAME
SDLx::Widget::Sprite - a drawable image
SYNOPSIS
use SDL;
use SDL::Image;
use SDL::Rect;
use SDLx::Widget::Sprite;
...
my $surface = SDL::Image::load('myimage.png');
my $clip_rect = SDL::Rect->new(0,0,32,32);
my $sprite = SDLx::Widget::Sprite->new($surface, $clip_rect);
my $pos = SDL::Rect->new(67, 89, 32, 32);
$sprite->x; # returns x value of sprite
$sprite->x(64); # set x clipping location of sprite
$sprite->draw($screen, $pos) # draw the sprite to a surface,
# in this case $screen, at the
# screen coordinates indicated by
# $pos
DESCRIPTION
SDLx::Widget::Sprite is essentially an SDL::Surface with an added draw() method, and accessor methods that allow you to define the clipping regions of the Sprite without having to create an SDL::Rect every time you want to change the clipping region.
METHODS
x
-
Accessor. Sets the left-most value of the clipping region
y
-
Accessor. Sets the top-most value of the clipping region
w
-
Accessor. Sets the width of the clipping region
h
-
Accessor. Sets the height of the clipping region
draw
-
Takes two arguments, an SDL::Surface and an SDL::Rect. Draws the Sprite on the SDL::Surface at the location designated by the SDL::Rect.
AUTHOR
Dustin Mays <dork.fish.wat@gmail.com>
SEE ALSO
SDL::Surface, SDL_Perl