From: Tobias Leich
Date: Fri, 27 Aug 2010 15:28:54 +0000 (+0200)
Subject: updated docs for layermanager and layer
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3030a264d15d5b4d56772f42b1fb2d645aa70e29;p=sdlgit%2FSDL-Site.git
updated docs for layermanager and layer
---
diff --git a/pages/SDL.html-inc b/pages/SDL.html-inc
index 865ff4e..c5147c2 100644
--- a/pages/SDL.html-inc
+++ b/pages/SDL.html-inc
@@ -251,6 +251,7 @@ The actual delay may be longer than specified depending on the underlying OS.
Fedora
Gabor Szabo (szabgab) <szabgab@gmail.com>
Guillaue Cottenceau (gc) <gc@mandrakesoft.com>
+Heikki Meht&195;nen (hmehta/hejki) <heikki@mehtanen.fi>
James King
James Wright <jwright@cpan.org>
Jeffrey T. Palmer (jtpalmer) <jeffrey.t.palmer@gmail.com>
diff --git a/pages/SDLx-Layer.html-inc b/pages/SDLx-Layer.html-inc
index bdfbd1e..4bfcbd6 100644
--- a/pages/SDLx-Layer.html-inc
+++ b/pages/SDLx-Layer.html-inc
@@ -14,8 +14,8 @@
w
h
surface
-clip
pos
+clip
data
ahead
behind
@@ -48,15 +48,30 @@
use SDLx::Layer;
use SDLx::LayerManager;
-
+ use SDL::Image;
+ use SDL::Surface;
+ use SDL::Video;
-
-DESCRIPTION
Top
-
+ # creating layers
+ my $layer1 = SDLx::Layer->new( SDL::Image::load('image1.png'), {userdata => '7'} );
+ my $layer2 = SDLx::Layer->new( SDL::Image::load('image2.png'), 100, 200, {userdata => '42'} );
+
+ # creating the manager that holds the layers
+ my $layermanager = SDLx::LayerManager->new();
+ $layermanager->add( $layer1 );
+ $layermanager->add( $layer2 );
+ my $display = # create your video surface here
+ $layer1->foreground;
+ printf( "%s\n", $layer1->behind->[0]->data->{userdata} ); # prints 42
+
+
+DESCRIPTION
Top
+
+
A layer (see SDLx::Layer) is an SDL::Surface, the position of the surface on screen and some additional information, e.g. ingame states.
METHODS
Top
@@ -65,62 +80,150 @@
new
+
my $layer = SDLx::Layer->new( $surface );
+ my $layer = SDLx::Layer->new( $surface, %data );
+ my $layer = SDLx::Layer->new( $surface, $pos_x, %data );
+ my $layer = SDLx::Layer->new( $surface, $pos_x, $pos_y, %data );
+ my $layer = SDLx::Layer->new( $surface, $pos_x, $pos_y, $clip_w, %data );
+ my $layer = SDLx::Layer->new( $surface, $pos_x, $pos_y, $clip_w, $clip_h, %data );
+
+
+
This constructs the layer object. See how you can omit the position and dimension of the layer. The hash %data
is for your use only.
+The layer object just pass it through.
index
+
my $index = $layer->index;
+
+
+
The method index
represents the z-index ot this layer within its layermanager.
x
+
my $x = $layer->x;
+
+
+
This is a shortcut for $layer->pos->x.
y
+
my $y = $layer->y;
+
+
+
This is a shortcut for $layer->pos->y.
w
+
my $w = $layer->w;
+
+
+
This is a shortcut for $layer->clip->w.
h
+
my $h = $layer->h;
+
+
+
This is a shortcut for $layer->pos->h.
surface
+
my $surface = $layer->surface;
+ my $surface = $layer->surface( $new_surface );
-
-clip
-
+
+
Example:
+
SDL::Video::blit_surface( $layer->surface, $layer->clip, $destination_surface, $layer->pos );
+
+
+
This method let you retrive the current or set a new surface.
pos
+
my $rect = $layer->pos;
+
+
+
The method pos
returns an SDL::Rect object. The pos x and y are stored there.
+
Example:
+
SDL::Video::blit_surface( $layer->surface, $layer->clip, $destination_surface, $layer->pos );
+
+
+
+
+clip
+
+
my $rect = $layer->clip;
+
+
+
The method clip
returns an SDL::Rect object. The clip width and height are stored there.
+
Example:
+
SDL::Video::blit_surface( $layer->surface, $layer->clip, $destination_surface, $layer->pos );
+
+
data
+
my %data = %{ $layer->data };
+ my %data = %{ $layer->data( %new_data) };
+
+
+
This method returns the hash %data
. You can set %data
by passing a hash.
ahead
+
my @layers = $layer->ahead;
+
+
+
This method returns all layers that are ahead of the given layer.
+Ahead means that a layer has a higher z-index and is blitted over the given layer.
+
Note: This method doesn't check for transparency. This will change in future versions.
behind
+
my @layers = $layer->behind;
+
+
+
This method returns all layers that are behind of the given layer.
+Behind means that a layer has a lower z-index and is blitted over the given layer.
+
Note: This method doesn't check for transparency. This will change in future versions.
attach
+
$layer->attach( $x, $y );
+
+
+
This function makes the given layer sticky to the mouse. If you move the mouse the layer will follow.
+The layermanager blits this layer at last, so they will appear on top of all layers.
+
$x
and $y
should be set to the coords of the mouse, e.g. the coords of the mouse click.
+If you omit $x
and $y
the layer obtains them via SDL::Events::get_mouse_state.
+
Note: The z-index is not changed for the given layer.
detach_xy
+
$layer->detach_xy( $x, $y );
+
+
+
detach_xy
detaches the prevously attached layer to the given coords. The upper left corner of this layer will be at $x
and $y
.
foreground
+
$layer->foreground;
+
+
+
This method moves the given layer to the foreground so that it is blittet on top of the other layers.
BUGS
Top
diff --git a/pages/SDLx-LayerManager.html-inc b/pages/SDLx-LayerManager.html-inc
index 4aed8af..648d91c 100644
--- a/pages/SDLx-LayerManager.html-inc
+++ b/pages/SDLx-LayerManager.html-inc
@@ -160,18 +160,41 @@ Behind means that a layer has a lower z-index and is blitted before the given la
attach
+
$layermanager->attach( $layer, $x, $y );
+ $layermanager->attach( @layers, $x, $y );
+
+
+
This function makes the given layer(s) sticky to the mouse. If you move the mouse the layer(s) will follow.
+The layermanager blits these layers at last, so they will appear on top of all layers.
+
$x
and $y
should be set to the coords of the mouse, e.g. the coords of the mouse click.
+If you omit $x
and $y
the layermanager obtains them via SDL::Events::get_mouse_state.
+
Note: The z-index is not changed for the given layers.
detach_xy
+
$layermanager->detach_xy( $x, $y );
+
+
+
detach_xy
detaches the prevously attached layers to the given coords. The upper left corner of the backmost layer will be at $x
and $y
.
+The other layers are positioned relative to the backmost layer just like before.
detach_back
+
$layermanager->detach_back( );
+
+
+
detach_back
detaches the prevously attached layers back to the position where they were attached.
foreground
+
$layermanager->foreground( $layer );
+ $layermanager->foreground( @layers );
+
+
+
This method moves the given layer(s) to the foreground so that they are blittet on top of the other layers.
BUGS
Top
diff --git a/pages/documentation.html-inc b/pages/documentation.html-inc
index 85260d8..2e79eac 100644
--- a/pages/documentation.html-inc
+++ b/pages/documentation.html-inc
@@ -1,2 +1,2 @@
+Documentation (latest development branch)
Core |
| SDL | - Simple DirectMedia Layer for Perl |
| SDL::Credits | - Authors and contributors of the SDL Perl project |
| SDL::Deprecated | - Log of Deprecated items per release |
| SDL::Time | - An SDL Perl extension for managing timers |
CDROM |
| SDL::CDROM | - SDL Bindings for the CDROM device |
Structure |
| SDL::CD | - SDL Bindings for structure SDL_CD |
| SDL::CDTrack | - SDL Bindings for structure SDL_CDTrack |
Events |
| SDL::Events | - Bindings to the Events Category in SDL API |
Mouse |
| SDL::Mouse | - SDL Bindings for the Mouse device |
Structure |
| SDL::Version | - SDL Bindings for structure SDL_Version |
Video |
| SDL::Video | - Bindings to the video category in SDL API |
Image |
| SDL::Image | - Bindings for the SDL_Image library |
TTF |
| SDL::TTF | - True Type Font functions (libfreetype) |
UNCATEGORIZED |
| SDLx::Controller | - Handles the loops for event, movement and rendering |