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="#index">index</a></li>
12 <li><a href="#x">x</a></li>
13 <li><a href="#y">y</a></li>
14 <li><a href="#w">w</a></li>
15 <li><a href="#h">h</a></li>
16 <li><a href="#surface">surface</a></li>
17 <li><a href="#pos">pos</a></li>
18 <li><a href="#clip">clip</a></li>
19 <li><a href="#data">data</a></li>
20 <li><a href="#ahead">ahead</a></li>
21 <li><a href="#behind">behind</a></li>
22 <li><a href="#attach">attach</a></li>
23 <li><a href="#detach_xy">detach_xy</a></li>
24 <li><a href="#foreground">foreground</a></li>
27 <li><a href="#BUGS">BUGS</a></li>
28 <li><a href="#SUPPORT">SUPPORT</a></li>
29 <li><a href="#AUTHORS">AUTHORS</a></li>
30 <li><a href="#COPYRIGHT">COPYRIGHT</a></li>
31 <li><a href="#SEE_ALSO">SEE ALSO</a>
36 <h1 id="NAME">NAME</h1><p><a href="#TOP" class="toplink">Top</a></p>
37 <div id="NAME_CONTENT">
38 <p>SDLx::Layer - Storage object for surface and position information</p>
41 <h1 id="CATEGORY">CATEGORY </h1><p><a href="#TOP" class="toplink">Top</a></p>
42 <div id="CATEGORY_CONTENT">
46 <h1 id="SYNOPSIS">SYNOPSIS</h1><p><a href="#TOP" class="toplink">Top</a></p>
47 <div id="SYNOPSIS_CONTENT">
48 <pre> use SDLx::Layer;
49 use SDLx::LayerManager;
56 my $layer1 = SDLx::Layer->new( SDL::Image::load('image1.png'), {userdata => '7'} );
57 my $layer2 = SDLx::Layer->new( SDL::Image::load('image2.png'), 100, 200, {userdata => '42'} );
59 # creating the manager that holds the layers
60 my $layermanager = SDLx::LayerManager->new();
61 $layermanager->add( $layer1 );
62 $layermanager->add( $layer2 );
64 my $display = # create your video surface here
66 $layer1->foreground;
67 printf( "%s\n", $layer1->behind->[0]->data->{userdata} ); # prints 42
72 <h1 id="DESCRIPTION">DESCRIPTION</h1><p><a href="#TOP" class="toplink">Top</a></p>
73 <div id="DESCRIPTION_CONTENT">
74 <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>
77 <h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p>
78 <div id="METHODS_CONTENT">
82 <div id="new_CONTENT">
83 <pre> my $layer = SDLx::Layer->new( $surface );
84 my $layer = SDLx::Layer->new( $surface, %data );
85 my $layer = SDLx::Layer->new( $surface, $pos_x, %data );
86 my $layer = SDLx::Layer->new( $surface, $pos_x, $pos_y, %data );
87 my $layer = SDLx::Layer->new( $surface, $pos_x, $pos_y, $clip_w, %data );
88 my $layer = SDLx::Layer->new( $surface, $pos_x, $pos_y, $clip_w, $clip_h, %data );
91 <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.
92 The layer object just pass it through.</p>
95 <h2 id="index">index</h2>
96 <div id="index_CONTENT">
97 <pre> my $index = $layer->index;
100 <p>The method <code>index</code> represents the z-index ot this layer within its layermanager.</p>
105 <pre> my $x = $layer->x;
108 <p>This is a shortcut for $layer->pos->x.</p>
113 <pre> my $y = $layer->y;
116 <p>This is a shortcut for $layer->pos->y.</p>
121 <pre> my $w = $layer->w;
124 <p>This is a shortcut for $layer->clip->w.</p>
129 <pre> my $h = $layer->h;
132 <p>This is a shortcut for $layer->pos->h.</p>
135 <h2 id="surface">surface</h2>
136 <div id="surface_CONTENT">
137 <pre> my $surface = $layer->surface;
138 my $surface = $layer->surface( $new_surface );
141 <p><strong>Example</strong>:</p>
142 <pre> SDL::Video::blit_surface( $layer->surface, $layer->clip, $destination_surface, $layer->pos );
145 <p>This method let you retrive the current or set a new surface.</p>
148 <h2 id="pos">pos</h2>
149 <div id="pos_CONTENT">
150 <pre> my $rect = $layer->pos;
153 <p>The method <code>pos</code> returns an SDL::Rect object. The pos x and y are stored there.</p>
154 <p><strong>Example</strong>:</p>
155 <pre> SDL::Video::blit_surface( $layer->surface, $layer->clip, $destination_surface, $layer->pos );
160 <h2 id="clip">clip</h2>
161 <div id="clip_CONTENT">
162 <pre> my $rect = $layer->clip;
165 <p>The method <code>clip</code> returns an SDL::Rect object. The clip width and height are stored there.</p>
166 <p><strong>Example</strong>:</p>
167 <pre> SDL::Video::blit_surface( $layer->surface, $layer->clip, $destination_surface, $layer->pos );
172 <h2 id="data">data</h2>
173 <div id="data_CONTENT">
174 <pre> my %data = %{ $layer->data };
175 my %data = %{ $layer->data( %new_data) };
178 <p>This method returns the hash <code>%data</code>. You can set <code>%data</code> by passing a hash.</p>
181 <h2 id="ahead">ahead</h2>
182 <div id="ahead_CONTENT">
183 <pre> my @layers = $layer->ahead;
186 <p>This method returns all layers that are ahead of the given layer.
187 Ahead means that a layer has a higher z-index and is blitted over the given layer.</p>
188 <p><strong>Note</strong>: This method doesn't check for transparency. This will change in future versions.</p>
191 <h2 id="behind">behind</h2>
192 <div id="behind_CONTENT">
193 <pre> my @layers = $layer->behind;
196 <p>This method returns all layers that are behind of the given layer.
197 Behind means that a layer has a lower z-index and is blitted over the given layer.</p>
198 <p><strong>Note</strong>: This method doesn't check for transparency. This will change in future versions.</p>
201 <h2 id="attach">attach</h2>
202 <div id="attach_CONTENT">
203 <pre> $layer->attach( $x, $y );
206 <p>This function makes the given layer sticky to the mouse. If you move the mouse the layer will follow.
207 The layermanager blits this layer at last, so they will appear on top of all layers.</p>
208 <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.
209 If you omit <code>$x</code> and <code>$y</code> the layer obtains them via SDL::Events::get_mouse_state.</p>
210 <p><strong>Note</strong>: The z-index is not changed for the given layer.</p>
213 <h2 id="detach_xy">detach_xy</h2>
214 <div id="detach_xy_CONTENT">
215 <pre> $layer->detach_xy( $x, $y );
218 <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>
221 <h2 id="foreground">foreground</h2>
222 <div id="foreground_CONTENT">
223 <pre> $layer->foreground;
226 <p>This method moves the given layer to the foreground so that it is blittet on top of the other layers.</p>
229 <h1 id="BUGS">BUGS</h1><p><a href="#TOP" class="toplink">Top</a></p>
230 <div id="BUGS_CONTENT">
231 <p>Report at sdlperl.ath.cx</p>
234 <h1 id="SUPPORT">SUPPORT</h1><p><a href="#TOP" class="toplink">Top</a></p>
235 <div id="SUPPORT_CONTENT">
236 <p>#sdl irc.perl.org</p>
239 <h1 id="AUTHORS">AUTHORS</h1><p><a href="#TOP" class="toplink">Top</a></p>
240 <div id="AUTHORS_CONTENT">
241 <p>See <a href="/SDL.html#AUTHORS">/SDL.html#AUTHORS</a>.</p>
244 <h1 id="COPYRIGHT">COPYRIGHT</h1><p><a href="#TOP" class="toplink">Top</a></p>
245 <div id="COPYRIGHT_CONTENT">
246 <p>This program is free software; you can redistribute
247 it and/or modify it under the same terms as Perl itself.</p>
248 <p>The full text of the license can be found in the
249 LICENSE file included with this module.</p>
256 <h1 id="SEE_ALSO">SEE ALSO</h1><p><a href="#TOP" class="toplink">Top</a></p>
257 <div id="SEE_ALSO_CONTENT">
258 <p>perl(1), SDL(2).</p>