Class Rubygame::EventTriggers::OrTrigger
In: lib/rubygame/event_triggers.rb
lib/rubygame/event_triggers.rb
Parent: Object

OrTrigger is an event trigger which contains one or more other triggers, and fires when an event matches one or more of its triggers.

Contrast with AndTrigger.

Methods

match?   match?   new   new  

Public Class methods

Initialize a new instance of OrTrigger, containing the given triggers.

*triggers:The triggers to contain. (Array of triggers, required)

Example:

  is_red = AttrTrigger.new( :color => :red )
  is_blue = AttrTrigger.new( :color => :blue )

  # Matches only an event which has EITHER:
  #  1. #color == :red, OR
  #  2. #color == :blue
  is_red_or_blue = OrTrigger.new( is_red, is_blue )

  # More complex example with nested logic triggers:

  changed = InstanceOfTrigger.new( ColorChanged )

  changed_to_red_or_blue =
    AndTrigger.new( changed, is_red_or_blue )

Initialize a new instance of OrTrigger, containing the given triggers.

*triggers:The triggers to contain. (Array of triggers, required)

Example:

  is_red = AttrTrigger.new( :color => :red )
  is_blue = AttrTrigger.new( :color => :blue )

  # Matches only an event which has EITHER:
  #  1. #color == :red, OR
  #  2. #color == :blue
  is_red_or_blue = OrTrigger.new( is_red, is_blue )

  # More complex example with nested logic triggers:

  changed = InstanceOfTrigger.new( ColorChanged )

  changed_to_red_or_blue =
    AndTrigger.new( changed, is_red_or_blue )

Public Instance methods

Returns true if the event matches one or more of the triggers that the OrTrigger contains.

Returns true if the event matches one or more of the triggers that the OrTrigger contains.

[Validate]