Method: Actor#on_collision_do

Defined in:
lib/fantasy/actor.rb

#on_collision_do(other) ⇒ Object

This method is triggered when Actor collides with another Actor

Examples:

Limit Actor movement horizontally

class Player < Actor
  def on_collision_do(other)
    if other.name == "bullet"
      destroy
    end
  end
end


501
502
503
# File 'lib/fantasy/actor.rb', line 501

def on_collision_do(other)
  instance_exec(other, &@on_collision_callback) unless @on_collision_callback.nil?
end