.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" 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::Layer 3pm" .TH pods::SDLx::Layer 3pm "2020-11-09" "perl v5.32.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::Layer \- Storage object for surface and position information .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 \& \& $layer1\->foreground; \& printf( "%s\en", $layer1\->behind\->[0]\->data\->{userdata} ); # prints 42 .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" A layer (see SDLx::Layer) is an SDL::Surface, the position of the surface on screen and some additional information, e.g. ingame states. .SH "METHODS" .IX Header "METHODS" .SS "new" .IX Subsection "new" .Vb 6 \& 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 ); .Ve .PP This constructs the layer object. See how you can omit the position and dimension of the layer. The hash \f(CW%data\fR is for your use only. The layer object just pass it through. .SS "index" .IX Subsection "index" .Vb 1 \& my $index = $layer\->index; .Ve .PP The method \f(CW\*(C`index\*(C'\fR represents the z\-index of this layer within its layermanager. .SS "x" .IX Subsection "x" .Vb 1 \& my $x = $layer\->x; .Ve .PP This is a shortcut for \f(CW$layer\fR\->pos\->x. .SS "y" .IX Subsection "y" .Vb 1 \& my $y = $layer\->y; .Ve .PP This is a shortcut for \f(CW$layer\fR\->pos\->y. .SS "w" .IX Subsection "w" .Vb 1 \& my $w = $layer\->w; .Ve .PP This is a shortcut for \f(CW$layer\fR\->clip\->w. .SS "h" .IX Subsection "h" .Vb 1 \& my $h = $layer\->h; .Ve .PP This is a shortcut for \f(CW$layer\fR\->pos\->h. .SS "surface" .IX Subsection "surface" .Vb 2 \& my $surface = $layer\->surface; \& my $surface = $layer\->surface( $new_surface ); .Ve .PP \&\fBExample\fR: .PP .Vb 1 \& SDL::Video::blit_surface( $layer\->surface, $layer\->clip, $destination_surface, $layer\->pos ); .Ve .PP This method let you retrieve the current or set a new surface. .SS "pos" .IX Subsection "pos" .Vb 1 \& my $rect = $layer\->pos; .Ve .PP The method \f(CW\*(C`pos\*(C'\fR returns an SDL::Rect object. The pos x and y are stored there. .PP \&\fBExample\fR: .PP .Vb 1 \& SDL::Video::blit_surface( $layer\->surface, $layer\->clip, $destination_surface, $layer\->pos ); .Ve .SS "clip" .IX Subsection "clip" .Vb 1 \& my $rect = $layer\->clip; .Ve .PP The method \f(CW\*(C`clip\*(C'\fR returns an SDL::Rect object. The clip width and height are stored there. .PP \&\fBExample\fR: .PP .Vb 1 \& SDL::Video::blit_surface( $layer\->surface, $layer\->clip, $destination_surface, $layer\->pos ); .Ve .SS "data" .IX Subsection "data" .Vb 2 \& my %data = %{ $layer\->data }; \& my %data = %{ $layer\->data( %new_data) }; .Ve .PP This method returns the hash \f(CW%data\fR. You can set \f(CW%data\fR by passing a hash. .SS "ahead" .IX Subsection "ahead" .Vb 1 \& my @layers = $layer\->ahead; .Ve .PP 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. .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 = $layer\->behind; .Ve .PP 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. .PP \&\fBNote\fR: This method doesn't check for transparency. This will change in future versions. .SS "attach" .IX Subsection "attach" .Vb 1 \& $layer\->attach( $x, $y ); .Ve .PP 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. .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 layer obtains them via SDL::Events::get_mouse_state. .PP \&\fBNote\fR: The z\-index is not changed for the given layer. .SS "detach_xy" .IX Subsection "detach_xy" .Vb 1 \& $layer\->detach_xy( $x, $y ); .Ve .PP \&\f(CW\*(C`detach_xy\*(C'\fR detaches the previously attached layer to the given coords. The upper left corner of this layer will be at \f(CW$x\fR and \f(CW$y\fR. .SS "foreground" .IX Subsection "foreground" .Vb 1 \& $layer\->foreground; .Ve .PP This method moves the given layer to the foreground so that it is 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).