Method: Actor#name

Defined in:
lib/fantasy/actor.rb

#nameString

The value to internal name of this Actor.

It is useful for collision management for example.

Default (same as image_name).

Examples:

Set name

actor = Actor.new("image")
actor.name = "spaceship"

Used in collision trigger

actor = Actor.new("image")
actor.on_collision do |other|
  if other.name == "enemy"
    # damage
  end
end

Used with collision_with

actor = Actor.new("image")
actor.collision_with = ["enemy", "bullet"]

Returns:

  • (String)

    the actual name



190
191
192
# File 'lib/fantasy/actor.rb', line 190

def name
  @name
end