GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
pods::SDLx::Layer(3) User Contributed Perl Documentation pods::SDLx::Layer(3)

SDLx::Layer - Storage object for surface and position information

Extension

  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('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

A layer (see SDLx::Layer) is an SDL::Surface, the position of the surface on screen and some additional information, e.g. ingame states.

  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 );

This constructs the layer object. See how you can omit the position and dimension of the layer. The hash %data is for your use only. The layer object just pass it through.

  my $index = $layer->index;

The method "index" represents the z-index of this layer within its layermanager.

  my $x = $layer->x;

This is a shortcut for $layer->pos->x.

  my $y = $layer->y;

This is a shortcut for $layer->pos->y.

  my $w = $layer->w;

This is a shortcut for $layer->clip->w.

  my $h = $layer->h;

This is a shortcut for $layer->pos->h.

  my $surface = $layer->surface;
  my $surface = $layer->surface( $new_surface );

Example:

  SDL::Video::blit_surface( $layer->surface, $layer->clip, $destination_surface, $layer->pos );

This method let you retrieve the current or set a new surface.

  my $rect = $layer->pos;

The method "pos" returns an SDL::Rect object. The pos x and y are stored there.

Example:

  SDL::Video::blit_surface( $layer->surface, $layer->clip, $destination_surface, $layer->pos );

  my $rect = $layer->clip;

The method "clip" returns an SDL::Rect object. The clip width and height are stored there.

Example:

  SDL::Video::blit_surface( $layer->surface, $layer->clip, $destination_surface, $layer->pos );

  my %data = %{ $layer->data };
  my %data = %{ $layer->data( %new_data) };

This method returns the hash %data. You can set %data by passing a hash.

  my @layers = $layer->ahead;

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.

Note: This method doesn't check for transparency. This will change in future versions.

  my @layers = $layer->behind;

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.

Note: This method doesn't check for transparency. This will change in future versions.

  $layer->attach( $x, $y );

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.

$x and $y should be set to the coords of the mouse, e.g. the coords of the mouse click. If you omit $x and $y the layer obtains them via SDL::Events::get_mouse_state.

Note: The z-index is not changed for the given layer.

  $layer->detach_xy( $x, $y );

"detach_xy" detaches the previously attached layer to the given coords. The upper left corner of this layer will be at $x and $y.

  $layer->foreground;

This method moves the given layer to the foreground so that it is blitted on top of the other layers.

Report at sdlperl.ath.cx

#sdl irc.perl.org

See "AUTHORS" in SDL.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.

perl(1), SDL(2).
2022-06-07 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.