X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pages%2FSDLx-App.html-inc;h=2ed4ee399181af79c952be620c43da818906e5ed;hb=e1ec9f6e00ef090d063bc417e9683d40fc49b26f;hp=ca61336f28932d06fbbaa4afc879c4de4dbd07d3;hpb=609469b72b92a5718bf37dfc22c754c4b52bb28a;p=sdlgit%2FSDL-Site.git diff --git a/pages/SDLx-App.html-inc b/pages/SDLx-App.html-inc index ca61336..2ed4ee3 100644 --- a/pages/SDLx-App.html-inc +++ b/pages/SDLx-App.html-inc @@ -8,7 +8,10 @@
SDLx::App::loop
is a simple event loop method which takes a reference to a hash
-of event handler subroutines. The keys of the hash must be SDL event types such
-as SDL_QUIT(), SDL_KEYDOWN(), and the like. When called, the event method recieves
-as its parameter the event object used in the loop.
Example:
-my $app = SDLx::App->new( - title => "test.app", - width => 800, - height => 600, - depth => 32 - ); - - my %actions = ( - SDL_QUIT() => sub { exit(0); }, - SDL_KEYDOWN() => sub { print "Key Pressed" }, - ); - - $app->loop( \%actions ); - -- -
SDLx::App::sync
encapsulates the various methods of syncronizing the screen with the
@@ -212,6 +191,31 @@ in addition to the attribute selector, the value will be set. SDL:::App::a
always returns the current value of the given attribute, or croaks on failure.
SDLx::App
is a SDLx::Controller
. Use the event, show and handlers to run the app.
use SDL; + use SDLx::App; + + use SDL::Event; #Where ever the event call back is processed + + my $app = SDLx::App->new( width => 200, height => 200); + + $app->add_event_handler( sub{ return 0 if $_[0]->type == SDL_QUIT; return 1}); + + $app->add_show_handler( sub{ $app->update() } ); + + $app->add_move_handler( + sub{ + #calc your physics here + } ); + + $app->run(); + ++
see SDLx::Controller for more details.
+ +See AUTHORS in SDL.