SDL::Button - A multi state SDL Button


    # the image to use for the button
    $P0 = new PerlString
    $P0 = "filename/to/image.png"

    # create the button
    $I0 = find_type 'SDL::Button'
    button = new $I0, $P0

    # set the position
    button.'xpos'( 10 )
    button.'ypos'( 10 )

    # set the number of states    
    button.'states'( 2 )

    # activate the second status (first is 0)
    button = 1

    # draw the button
    button."draw"( screen )


A button uses an image containing several images representing different states of a button. You can change the button status at any time, the button will then be drawn differently. Please have a look at examples/sdl/minesweeper/smiley.png for an example.


An SDL::Button object has the following methods:

button = new ID, name



states( count )

pos( x, y )

size( width, height )

draw( screen )

click( x, y )

raise( arg )

setAction( status, callback )


Jens Rieks <parrot at jensbeimsurfen dot de> is the author and maintainer. Please send patches and suggestions to the Perl 6 Internals mailing list.


Copyright (c) 2004, The Perl Foundation.