X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pages%2FSDLx-Layer.html-inc;h=d5b2c57e70a70fca61f72037a5e1776b4feed509;hb=1dbe16975541da864f8bfa5169c89a2ab8893bf2;hp=556b041573cb8bbfe1c865852b0d4a686d1ba886;hpb=285d0cd289790209bcd9d141d63fd6fce74a2ee4;p=sdlgit%2FSDL-Site.git diff --git a/pages/SDLx-Layer.html-inc b/pages/SDLx-Layer.html-inc index 556b041..d5b2c57 100644 --- a/pages/SDLx-Layer.html-inc +++ b/pages/SDLx-Layer.html-inc @@ -14,8 +14,8 @@
  • w
  • h
  • surface
  • -
  • clip
  • pos
  • +
  • clip
  • data
  • ahead
  • behind
  • @@ -26,7 +26,7 @@
  • BUGS
  • SUPPORT
  • -
  • AUTHOR
  • +
  • AUTHORS
  • COPYRIGHT
  • SEE ALSO
  • @@ -35,7 +35,7 @@

    NAME

    Top

    -

    SDLx::Layer - Extension ...

    +

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

    CATEGORY

    Top

    @@ -48,15 +48,30 @@
      use SDLx::Layer;
       use SDLx::LayerManager;
     
    -
    + use SDL::Image; + use SDL::Surface; + use SDL::Video; - -

    DESCRIPTION

    Top

    -
    + # 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 + +
    +

    DESCRIPTION

    Top

    +
    +

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

    METHODS

    Top

    @@ -65,62 +80,150 @@

    new

    +
      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.

    index

    +
      my $index = $layer->index;
    +
    +
    +

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

    x

    +
      my $x = $layer->x;
    +
    +
    +

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

    y

    +
      my $y = $layer->y;
    +
    +
    +

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

    w

    +
      my $w = $layer->w;
    +
    +
    +

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

    h

    +
      my $h = $layer->h;
    +
    +
    +

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

    surface

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

    clip

    -
    + +

    Example:

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

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

    pos

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

    clip

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

    data

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

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

    ahead

    +
      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.

    behind

    +
      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.

    attach

    +
      $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.

    detach_xy

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

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

    foreground

    +
      $layer->foreground;
    +
    +
    +

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

    BUGS

    Top

    @@ -133,15 +236,9 @@

    #sdl irc.perl.org

    -

    AUTHOR

    Top

    -
    -
        Tobias Leich
    -    CPAN ID: FROGGS
    -    ---
    -    froggs@cpan.org
    -    http://sdl.perl.org
    -
    -
    +

    AUTHORS

    Top

    +
    +

    See /SDL.html#AUTHORS.

    COPYRIGHT

    Top