.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "pods::SDLx::LayerManager 3pm" .TH pods::SDLx::LayerManager 3pm "2022-10-19" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SDLx::LayerManager \- Extension for managing layers in a 2D world .SH "CATEGORY" .IX Header "CATEGORY" Extension .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& use SDLx::Layer; \& use SDLx::LayerManager; \& \& use SDL::Image; \& use SDL::Surface; \& use SDL::Video; \& \& # creating layers \& my $layer1 = SDLx::Layer\->new( SDL::Image::load(\*(Aqimage1.png\*(Aq), {userdata => \*(Aq7\*(Aq} ); \& my $layer2 = SDLx::Layer\->new( SDL::Image::load(\*(Aqimage2.png\*(Aq), 100, 200, {userdata => \*(Aq42\*(Aq} ); \& \& # 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 \& \& $layermanager\->blit( $display ); \& \& # accessing the layer at point(x,y) \& print( $layermanager\->by_position( 150, 200 )\->data\->{userdata} ); # should print \*(Aq42\*(Aq .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" 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. .PP 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. .PP You will even be able to attach one or more layers to the mouse, e.g. for simulation some drag&drop functionality. .SH "METHODS" .IX Header "METHODS" .SS "new" .IX Subsection "new" .Vb 1 \& my $layermanager = SDLx::LayerManager\->new(); .Ve .PP This creates your layermanager object. It doesn't take any parameters. .SS "add" .IX Subsection "add" .Vb 2 \& $layermanager\->add( $layer ); \& $layermanager\->add( SDLx::Layer\->new( $surface, $x, $y, $options ) ); .Ve .PP Call \f(CW\*(C`add\*(C'\fR to push an SDLx::Layer object to the layermanager. .SS "layers" .IX Subsection "layers" .Vb 2 \& my @layers = @{ $layermanager\->layers }; \& my $first_layer = $layermanager\->layers\->[0]; .Ve .PP The method \f(CW\*(C`layers\*(C'\fR returns all layers that were added before. .SS "layer" .IX Subsection "layer" .Vb 1 \& my $layer = $layermanager\->layer( $index ); .Ve .PP To obtain only one layer at index \f(CW$index\fR use this function. \f(CW$index\fR ranges from \f(CW0\fR to \f(CW\*(C`length \- 1\*(C'\fR. .SS "length" .IX Subsection "length" .Vb 1 \& my $length = $layermanager\->length(); .Ve .PP This method returns the count of the added layers. .SS "blit" .IX Subsection "blit" .Vb 1 \& $layermanager\->blit( $surface ); .Ve .PP This method blits all layers to the surface (e.g. your video surface). .SS "by_position" .IX Subsection "by_position" .Vb 1 \& my $layer = $layermanager\->by_position( $x, $y ); .Ve .PP \&\f(CW\*(C`by_position\*(C'\fR returns the \f(CW\*(C`SDLx::Layer\*(C'\fR object at point \f(CW\*(C`$x $y\*(C'\fR, which is not fully transparent at this pixel. .SS "ahead" .IX Subsection "ahead" .Vb 1 \& my @layers = @{ $layermanager\->ahead( $index ) }; .Ve .PP This method returns all layers that are ahead of the given layer indicated by \f(CW$index\fR. Ahead means that a layer has a higher z\-index and is blitted over the given layer. .PP \&\fBNote\fR: This method doesn't check for transparency. This will change in future versions. .SS "behind" .IX Subsection "behind" .Vb 1 \& my @layers = @{ $layermanager\->behind( $index ) }; .Ve .PP This method returns all layers that are behind of the given layer indicated by \f(CW$index\fR. Behind means that a layer has a lower z\-index and is blitted before the given layer. .PP \&\fBNote\fR: This method doesn't check for transparency. This will change in future versions. .SS "attach" .IX Subsection "attach" .Vb 2 \& $layermanager\->attach( $layer, $x, $y ); \& $layermanager\->attach( @layers, $x, $y ); .Ve .PP 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. .PP \&\f(CW$x\fR and \f(CW$y\fR should be set to the coords of the mouse, e.g. the coords of the mouse click. If you omit \f(CW$x\fR and \f(CW$y\fR the layermanager obtains them via SDL::Events::get_mouse_state. .PP \&\fBNote\fR: The z\-index is not changed for the given layers. .SS "detach_xy" .IX Subsection "detach_xy" .Vb 1 \& $layermanager\->detach_xy( $x, $y ); .Ve .PP \&\f(CW\*(C`detach_xy\*(C'\fR detaches the previously attached layers to the given coords. The upper left corner of the backmost layer will be at \f(CW$x\fR and \f(CW$y\fR. The other layers are positioned relative to the backmost layer just like before. .SS "detach_back" .IX Subsection "detach_back" .Vb 1 \& $layermanager\->detach_back( ); .Ve .PP \&\f(CW\*(C`detach_back\*(C'\fR detaches the previously attached layers back to the position where they were attached. .SS "foreground" .IX Subsection "foreground" .Vb 2 \& $layermanager\->foreground( $layer ); \& $layermanager\->foreground( @layers ); .Ve .PP This method moves the given layer(s) to the foreground so that they are blitted on top of the other layers. .SH "BUGS" .IX Header "BUGS" Report at sdlperl.ath.cx .SH "SUPPORT" .IX Header "SUPPORT" #sdl irc.perl.org .SH "AUTHORS" .IX Header "AUTHORS" See \*(L"\s-1AUTHORS\*(R"\s0 in \s-1SDL\s0. .SH "COPYRIGHT" .IX Header "COPYRIGHT" This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .PP The full text of the license can be found in the \&\s-1LICENSE\s0 file included with this module. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBperl\fR\|(1), \s-1\fBSDL\s0\fR\|(2).