Method: Actor#on_collision

Defined in:
lib/fantasy/actor.rb

#on_collision(&block) ⇒ Object

The block to be executed when Actor collides with another Actor

Examples:

Collision detected with "bullet"

actor = Actor.new("image")
actor.on_collision do |other|
  if other.name == "bullet"
    actor.destroy
  end
end


437
438
439
# File 'lib/fantasy/actor.rb', line 437

def on_collision(&block)
  @on_collision_callback = block
end