Class | Rubygame::EventActions::MethodAction |
In: |
lib/rubygame/event_actions.rb
lib/rubygame/event_actions.rb |
Parent: | Object |
MethodAction is an event action used with EventHook. MethodAction takes a symbol giving the name of a method. When it is performed, it calls that method on the owner, passing it the event that triggered the hook.
Example:
class Player def aim_at( event ) self.crosshair_pos = event.pos end end player1 = Player.new EventHook.new( :owner => player1, :trigger => MouseMoveTrigger.new(), :action => MethodAction.new( :aim_at ) )
Create a new MethodAction using the given method name.
method_name: | the method to call when performing. (Symbol, required) |
Create a new MethodAction using the given method name.
method_name: | the method to call when performing. (Symbol, required) |
Call the method of the owner represented by @method_name, passing in the event as the only argument.
If that causes ArgumentError (e.g. because the method doesn‘t take an argument), calls again without any arguments.
If that also fails, this method re-raises the original error.