Module: ShatteredPack::KeyboardInput::ClassMethods

Defined in:
lib/shattered_pack/keyboard_input/keyboard_input.rb

Instance Method Summary collapse

Instance Method Details

#key(options = {}) ⇒ Object

Key pressing can take any of the following forms:

key :released => :up, :action => :clicked_up
key :pressed => :left, :action => :left_pressed
key :held => :down, :action => :move_down_fluidly

where each of the actions correspond to an actor function:

class ExampleView < ShatteredView::Base

def clicked_up
  #called when up is released
end
def left_pressed
  #called when left is released
end
def move_down_fluidly(time_elapsed)
  #called when down is held
end

end

Only key :pressed recieves the time_elapsed variable (as it is updated per frame)



33
34
35
# File 'lib/shattered_pack/keyboard_input/keyboard_input.rb', line 33

def key(options = {})
  before_init_call(:key, options)
end