Gtk2::Hexgrid::Sprite - an object to be drawn over a tile
my $sprite1 = $tile->set_background("images/squid.png"); my $sprite2 = $tile->set_text("blah", 18); my $sprite3 = new Gtk2::Hexgrid::Sprite("text", "blah", 15); my $sprite4 = new Gtk2::Hexgrid::Sprite("image", "imageName"); $sprite4->set_priority(5); $sprite4->attach($tile);
Use these if you want a background, some text, or some critters that aren't tied to a particular tile.
my $sprite3 = new Gtk2::Hexgrid::Sprite("text", "blah", 15); my $sprite4 = new Gtk2::Hexgrid::Sprite("image", "imageName");
The type, "text" or "image", is in the first field. If "text", the text and font size are in the next fields. If 'image', the image name is in the next field. The image name is used as a key to the actual image. Images are loaded by Gtk2::Hexgrid::load_image.
my $sprite = new_mobile Gtk2::Hexgrid::Sprite($hexgrid, $filename);
Automatically loads sprite. This method works well with penguin sprites.
my $newSprite = $sprite->copy();
Returns a clone of caller sprite.
$sprite->detach;
Removes self from its parent and starts floating in space
$sprite->attach($tile);
Performs a detach in reverse.
Each sprite has a priority, the default being 0. Sprites with lower priorities are drawn before sprites with higher priorities. I've given backgrounds a priority of -21.21, and text is 21.21. They are not round numbers because sprites with the same priority are prioritized by thich sprite was attached first, and that may cause weird behavior.
To install Gtk2::Hexgrid, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Gtk2::Hexgrid
CPAN shell
perl -MCPAN -e shell install Gtk2::Hexgrid
For more information on module installation, please visit the detailed CPAN module installation guide.