<li><a href="#w">w</a></li>
<li><a href="#h">h</a></li>
<li><a href="#surface">surface</a></li>
-<li><a href="#clip">clip</a></li>
<li><a href="#pos">pos</a></li>
+<li><a href="#clip">clip</a></li>
<li><a href="#data">data</a></li>
<li><a href="#ahead">ahead</a></li>
<li><a href="#behind">behind</a></li>
<pre> use SDLx::Layer;
use SDLx::LayerManager;
-</pre>
+ use SDL::Image;
+ use SDL::Surface;
+ use SDL::Video;
-</div>
-<h1 id="DESCRIPTION">DESCRIPTION</h1><p><a href="#TOP" class="toplink">Top</a></p>
-<div id="DESCRIPTION_CONTENT">
+ # 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
+</pre>
+</div>
+<h1 id="DESCRIPTION">DESCRIPTION</h1><p><a href="#TOP" class="toplink">Top</a></p>
+<div id="DESCRIPTION_CONTENT">
+<p>A layer (see SDLx::Layer) is an SDL::Surface, the position of the surface on screen and some additional information, e.g. ingame states.</p>
</div>
<h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p>
</div>
<h2 id="new">new</h2>
<div id="new_CONTENT">
+<pre> 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 );
+
+</pre>
+<p>This constructs the layer object. See how you can omit the position and dimension of the layer. The hash <code>%data</code> is for your use only.
+The layer object just pass it through.</p>
</div>
<h2 id="index">index</h2>
<div id="index_CONTENT">
+<pre> my $index = $layer->index;
+
+</pre>
+<p>The method <code>index</code> represents the z-index ot this layer within its layermanager.</p>
</div>
<h2 id="x">x</h2>
<div id="x_CONTENT">
+<pre> my $x = $layer->x;
+
+</pre>
+<p>This is a shortcut for $layer->pos->x.</p>
</div>
<h2 id="y">y</h2>
<div id="y_CONTENT">
+<pre> my $y = $layer->y;
+
+</pre>
+<p>This is a shortcut for $layer->pos->y.</p>
</div>
<h2 id="w">w</h2>
<div id="w_CONTENT">
+<pre> my $w = $layer->w;
+
+</pre>
+<p>This is a shortcut for $layer->clip->w.</p>
</div>
<h2 id="h">h</h2>
<div id="h_CONTENT">
+<pre> my $h = $layer->h;
+
+</pre>
+<p>This is a shortcut for $layer->pos->h.</p>
</div>
<h2 id="surface">surface</h2>
<div id="surface_CONTENT">
+<pre> my $surface = $layer->surface;
+ my $surface = $layer->surface( $new_surface );
-</div>
-<h2 id="clip">clip</h2>
-<div id="clip_CONTENT">
+</pre>
+<p><strong>Example</strong>:</p>
+<pre> SDL::Video::blit_surface( $layer->surface, $layer->clip, $destination_surface, $layer->pos );
+
+</pre>
+<p>This method let you retrive the current or set a new surface.</p>
</div>
<h2 id="pos">pos</h2>
<div id="pos_CONTENT">
+<pre> my $rect = $layer->pos;
+
+</pre>
+<p>The method <code>pos</code> returns an SDL::Rect object. The pos x and y are stored there.</p>
+<p><strong>Example</strong>:</p>
+<pre> SDL::Video::blit_surface( $layer->surface, $layer->clip, $destination_surface, $layer->pos );
+
+</pre>
+
+</div>
+<h2 id="clip">clip</h2>
+<div id="clip_CONTENT">
+<pre> my $rect = $layer->clip;
+
+</pre>
+<p>The method <code>clip</code> returns an SDL::Rect object. The clip width and height are stored there.</p>
+<p><strong>Example</strong>:</p>
+<pre> SDL::Video::blit_surface( $layer->surface, $layer->clip, $destination_surface, $layer->pos );
+
+</pre>
</div>
<h2 id="data">data</h2>
<div id="data_CONTENT">
+<pre> my %data = %{ $layer->data };
+ my %data = %{ $layer->data( %new_data) };
+
+</pre>
+<p>This method returns the hash <code>%data</code>. You can set <code>%data</code> by passing a hash.</p>
</div>
<h2 id="ahead">ahead</h2>
<div id="ahead_CONTENT">
+<pre> my @layers = $layer->ahead;
+
+</pre>
+<p>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.</p>
+<p><strong>Note</strong>: This method doesn't check for transparency. This will change in future versions.</p>
</div>
<h2 id="behind">behind</h2>
<div id="behind_CONTENT">
+<pre> my @layers = $layer->behind;
+
+</pre>
+<p>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.</p>
+<p><strong>Note</strong>: This method doesn't check for transparency. This will change in future versions.</p>
</div>
<h2 id="attach">attach</h2>
<div id="attach_CONTENT">
+<pre> $layer->attach( $x, $y );
+
+</pre>
+<p>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.</p>
+<p><code>$x</code> and <code>$y</code> should be set to the coords of the mouse, e.g. the coords of the mouse click.
+If you omit <code>$x</code> and <code>$y</code> the layer obtains them via SDL::Events::get_mouse_state.</p>
+<p><strong>Note</strong>: The z-index is not changed for the given layer.</p>
</div>
<h2 id="detach_xy">detach_xy</h2>
<div id="detach_xy_CONTENT">
+<pre> $layer->detach_xy( $x, $y );
+
+</pre>
+<p><code>detach_xy</code> detaches the prevously attached layer to the given coords. The upper left corner of this layer will be at <code>$x</code> and <code>$y</code>.</p>
</div>
<h2 id="foreground">foreground</h2>
<div id="foreground_CONTENT">
+<pre> $layer->foreground;
+
+</pre>
+<p>This method moves the given layer to the foreground so that it is blittet on top of the other layers.</p>
</div>
<h1 id="BUGS">BUGS</h1><p><a href="#TOP" class="toplink">Top</a></p>
</div>
<h2 id="attach">attach</h2>
<div id="attach_CONTENT">
+<pre> $layermanager->attach( $layer, $x, $y );
+ $layermanager->attach( @layers, $x, $y );
+
+</pre>
+<p>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.</p>
+<p><code>$x</code> and <code>$y</code> should be set to the coords of the mouse, e.g. the coords of the mouse click.
+If you omit <code>$x</code> and <code>$y</code> the layermanager obtains them via SDL::Events::get_mouse_state.</p>
+<p><strong>Note</strong>: The z-index is not changed for the given layers.</p>
</div>
<h2 id="detach_xy">detach_xy</h2>
<div id="detach_xy_CONTENT">
+<pre> $layermanager->detach_xy( $x, $y );
+
+</pre>
+<p><code>detach_xy</code> detaches the prevously attached layers to the given coords. The upper left corner of the backmost layer will be at <code>$x</code> and <code>$y</code>.
+The other layers are positioned relative to the backmost layer just like before.</p>
</div>
<h2 id="detach_back">detach_back</h2>
<div id="detach_back_CONTENT">
+<pre> $layermanager->detach_back( );
+
+</pre>
+<p><code>detach_back</code> detaches the prevously attached layers back to the position where they were attached.</p>
</div>
<h2 id="foreground">foreground</h2>
<div id="foreground_CONTENT">
+<pre> $layermanager->foreground( $layer );
+ $layermanager->foreground( @layers );
+
+</pre>
+<p>This method moves the given layer(s) to the foreground so that they are blittet on top of the other layers.</p>
</div>
<h1 id="BUGS">BUGS</h1><p><a href="#TOP" class="toplink">Top</a></p>