3 <h3 id="TOP">Index</h3>
5 <ul><li><a href="#NAME">NAME</a></li>
6 <li><a href="#CATEGORY">CATEGORY </a></li>
7 <li><a href="#SYNOPSIS">SYNOPSIS</a></li>
8 <li><a href="#DESCRIPTION">DESCRIPTION</a></li>
9 <li><a href="#METHODS">METHODS</a>
10 <ul><li><a href="#new">new</a></li>
11 <li><a href="#add">add</a></li>
12 <li><a href="#layers">layers</a></li>
13 <li><a href="#layer">layer</a></li>
14 <li><a href="#length">length</a></li>
15 <li><a href="#blit">blit</a></li>
16 <li><a href="#by_position">by_position</a></li>
17 <li><a href="#ahead">ahead</a></li>
18 <li><a href="#behind">behind</a></li>
19 <li><a href="#attach">attach</a></li>
20 <li><a href="#detach_xy">detach_xy</a></li>
21 <li><a href="#detach_back">detach_back</a></li>
22 <li><a href="#foreground">foreground</a></li>
25 <li><a href="#BUGS">BUGS</a></li>
26 <li><a href="#SUPPORT">SUPPORT</a></li>
27 <li><a href="#AUTHORS">AUTHORS</a></li>
28 <li><a href="#COPYRIGHT">COPYRIGHT</a></li>
29 <li><a href="#SEE_ALSO">SEE ALSO</a>
34 <h1 id="NAME">NAME</h1><p><a href="#TOP" class="toplink">Top</a></p>
35 <div id="NAME_CONTENT">
36 <p>SDLx::LayerManager - Extension for managing layers in a 2D world</p>
39 <h1 id="CATEGORY">CATEGORY </h1><p><a href="#TOP" class="toplink">Top</a></p>
40 <div id="CATEGORY_CONTENT">
44 <h1 id="SYNOPSIS">SYNOPSIS</h1><p><a href="#TOP" class="toplink">Top</a></p>
45 <div id="SYNOPSIS_CONTENT">
46 <pre> use SDLx::Layer;
47 use SDLx::LayerManager;
54 my $layer1 = SDLx::Layer->new( SDL::Image::load('image1.png'), {userdata => '7'} );
55 my $layer2 = SDLx::Layer->new( SDL::Image::load('image2.png'), 100, 200, {userdata => '42'} );
57 # creating the manager that holds the layers
58 my $layermanager = SDLx::LayerManager->new();
59 $layermanager->add( $layer1 );
60 $layermanager->add( $layer2 );
62 my $display = # create your video surface here
64 $layermanager->blit( $display );
66 # accessing the layer at point(x,y)
67 print( $layermanager->by_position( 150, 200 )->data->{userdata} ); # should print '42'
72 <h1 id="DESCRIPTION">DESCRIPTION</h1><p><a href="#TOP" class="toplink">Top</a></p>
73 <div id="DESCRIPTION_CONTENT">
74 <p>SDLx::LayerManager is a package to handle a bunch of layers. A layer (see SDLx::Layer) is an SDL::Surface, the position of the surface on screen and some additional information.</p>
75 <p>The layermanager gives you the opportunity to obtain the layer at a given point on screen and get the layers that are ahead or behind a layer.</p>
76 <p>You will even be able to attach one or more layers to the mouse, e.g. for simulation some drag&drop functionality.</p>
79 <h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p>
80 <div id="METHODS_CONTENT">
84 <div id="new_CONTENT">
85 <pre> my $layermanager = SDLx::LayerManager->new();
88 <p>This creates your layermanager object. It doesn't take any parameters.</p>
92 <div id="add_CONTENT">
93 <pre> $layermanager->add( $layer );
94 $layermanager->add( SDLx::Layer->new( $surface, $x, $y, $options ) );
97 <p>Call <code>add</code> to push an SDLx::Layer object to the layermanager.</p>
100 <h2 id="layers">layers</h2>
101 <div id="layers_CONTENT">
102 <pre> my @layers = @{ $layermanager->layers };
103 my $first_layer = $layermanager->layers->[0];
106 <p>The method <code>layers</code> returns all layers that were added before.</p>
109 <h2 id="layer">layer</h2>
110 <div id="layer_CONTENT">
111 <pre> my $layer = $layermanager->layer( $index );
114 <p>To obtain only one layer at index <code>$index</code> use this function. <code>$index</code> ranges from <code>0</code> to <code>lenght - 1</code>.</p>
117 <h2 id="length">length</h2>
118 <div id="length_CONTENT">
119 <pre> my $length = $layermanager->length();
122 <p>This method returns the count of the added layers.</p>
125 <h2 id="blit">blit</h2>
126 <div id="blit_CONTENT">
127 <pre> $layermanager->blit( $surface );
130 <p>This method blits all layers to the surface (e.g. your video surface).</p>
133 <h2 id="by_position">by_position</h2>
134 <div id="by_position_CONTENT">
135 <pre> my $layer = $layermanager->by_position( $x, $y );
138 <p><code>by_position</code> returns the <code>SDLx::Layer</code> object at point <code>$x $y</code>, which is not fully transparent at this pixel.</p>
141 <h2 id="ahead">ahead</h2>
142 <div id="ahead_CONTENT">
143 <pre> my @layers = @{ $layermanager->ahead( $index ) };
146 <p>This method returns all layers that are ahead of the given layer indicated by <code>$index</code>.
147 Ahead means that a layer has a higher z-index and is blitted over the given layer.</p>
148 <p><strong>Note</strong>: This method doesn't check for transparency. This will change in future versions.</p>
151 <h2 id="behind">behind</h2>
152 <div id="behind_CONTENT">
153 <pre> my @layers = @{ $layermanager->behind( $index ) };
156 <p>This method returns all layers that are behind of the given layer indicated by <code>$index</code>.
157 Behind means that a layer has a lower z-index and is blitted before the given layer.</p>
158 <p><strong>Note</strong>: This method doesn't check for transparency. This will change in future versions.</p>
161 <h2 id="attach">attach</h2>
162 <div id="attach_CONTENT">
165 <h2 id="detach_xy">detach_xy</h2>
166 <div id="detach_xy_CONTENT">
169 <h2 id="detach_back">detach_back</h2>
170 <div id="detach_back_CONTENT">
173 <h2 id="foreground">foreground</h2>
174 <div id="foreground_CONTENT">
177 <h1 id="BUGS">BUGS</h1><p><a href="#TOP" class="toplink">Top</a></p>
178 <div id="BUGS_CONTENT">
179 <p>Report at sdlperl.ath.cx</p>
182 <h1 id="SUPPORT">SUPPORT</h1><p><a href="#TOP" class="toplink">Top</a></p>
183 <div id="SUPPORT_CONTENT">
184 <p>#sdl irc.perl.org</p>
187 <h1 id="AUTHORS">AUTHORS</h1><p><a href="#TOP" class="toplink">Top</a></p>
188 <div id="AUTHORS_CONTENT">
189 <p>See <b>AUTHORS</b> in <cite>SDL</cite>.</p>
192 <h1 id="COPYRIGHT">COPYRIGHT</h1><p><a href="#TOP" class="toplink">Top</a></p>
193 <div id="COPYRIGHT_CONTENT">
194 <p>This program is free software; you can redistribute
195 it and/or modify it under the same terms as Perl itself.</p>
196 <p>The full text of the license can be found in the
197 LICENSE file included with this module.</p>
204 <h1 id="SEE_ALSO">SEE ALSO</h1><p><a href="#TOP" class="toplink">Top</a></p>
205 <div id="SEE_ALSO_CONTENT">
206 <p>perl(1), SDL(2).</p>