SDLx::Controller more methods #142

Open
kthakore opened this Issue Jul 26, 2011 · 0 comments

Comments

Projects
None yet
1 participant
Owner

kthakore commented Jul 26, 2011

This ticket will come in the form of the POD for some more methods I would like for SDLx::Controller.

=head2 add_handlers

$app->add_handlers(
event => [ @event_handlers ],
move => [ @move_handlers ],
show => [ @show_handlers ],
);

A combination of C<add_event_handler>, C<add_move_handler> and C<add_show_handler>. This is useful when used with C.

=head2 store

my $stored_handlers = $app->store;

Returns a scalar reference to C<$app>s currently added handlers. This reference will look like:
{
event => [ @event_handlers ],
move => [ @move_handlers ],
show => [ @show_handlers ],
}

This makes it easy to use C with C<add_handlers>. Example:

... Do stuff with old handlers, then on some event...

my $store = $app->store;
$app->remove_all_handlers;

... Now add the new handlers we want...

$app->add_event_handler(&foo);
$app->add_event_handler(&bar);
$app->add_event_handler(&baz);

... Later on when we want our old handlers back...

$app->add_handlers(%$store);

I'll put these in unless anyone has any problems or comments. The reason I want this is that it will make it extremely easy to switch between game modes and such. I'd use it to switch between the game and the level editor.

kthakore was assigned Jul 26, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment