lib/gamebox/core/input_manager.rb
# registers a block to be called when matching events are pulled from the SDL queue.
# ie 
# input_manager.register_hook KeyPressed do |evt|
#   # will be called on every key press
# end
# input_manager.register_hook KeyPressed, K_SPACE do |evt|
#   # will be called on every spacebar key press
# end
registers a block to be called when matching events are pulled from the SDL queue.
ie
input_manager.register_hook KeyPressed do |evt|
will be called on every key press
end
input_manager.register_hook KeyPressed, K_SPACE do |evt|
will be called on every spacebar key press
end
registers a block to be called when matching events are pulled from the SDL queue . ie input_manager . register_hook KeyPressed do |evt| will be called on every key press end input_manager . register_hook KeyPressed K_SPACE do |evt| will be called on every spacebar key press end
def register_hook(event_class, *event_ids, &block)
    event_class = :down if DOWN_EVENTS.include? event_class
    event_class = :up if UP_EVENTS.include? event_class
    return unless block_given?
    listener = eval("self", block.binding) 
    @block_self_lookup[block] = listener
    _register_hook listener, event_class, *event_ids, &block
  end
def register_hook ( event_class , * event_ids , & block ) event_class = :down if DOWN_EVENTS . include? event_class event_class = :up if UP_EVENTS . include? event_class return unless block_given? listener = eval ( "self" , block . binding ) @block_self_lookup [ block ] = listener _register_hook listener , event_class , * event_ids , & block end
registers a block to be called when matching events are pulled from the SDL queue.
registers a block to be called when matching events are pulled from the SDL queue .
event_class
<not_specific>
event_ids
<not_specific>
block
<not_specific>