Method: Actor#on_floor_do

Defined in:
lib/fantasy/actor.rb

#on_floor_doObject

This method is triggered when the Actor touches floor

Examples:

Change image when jumping

class Player < Actor
  def.on_floor_do
    self.image_name = "land"
    Clock.new { self.image_name = "walk" }.run_on(seconds: 0.8)
  end
end


538
539
540
# File 'lib/fantasy/actor.rb', line 538

def on_floor_do
  instance_exec(&@on_floor_callback) unless @on_floor_callback.nil?
end