Skip to content

Named handlers for SDLx::Controller #197

Closed
kthakore opened this Issue Jul 26, 2011 · 3 comments

3 participants

@kthakore
PerlGameDev member

What about get names for all handlers? For example:

$app->add_move_handler(player => sub{...});
$app->add_move_handler(unit1 => sub{...});
$app->add_move_handler(unit2 => sub{...});

...

$app->remove_move_handler('unit1');

It`s get more flexible behavior. Not need store indexes and use them, just use name what you set and you known.

To do:

  • Replace handlers array to hash
  • For save current behavior: set number as key for handler if key not specified

What do you think about that?

@kthakore kthakore was assigned Jul 26, 2011
@Blaizer
PerlGameDev member
Blaizer commented Aug 8, 2011

Handlers need to be called in order. Hashes aren't ordered.

@jtpalmer
PerlGameDev member
jtpalmer commented Aug 8, 2011

Use an array of pairs (arrays) then. Fall back to a number when no name is specified.

@Blaizer
PerlGameDev member
Blaizer commented Aug 11, 2011

Would be a much better idea to use an ordered hash module from cpan... but then that's another dependency.

@Blaizer Blaizer closed this Mar 25, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.