Sha256: 8da105f160469aa6ce591d454fea212d7bee95089a2fbcd9d18019af4645c34a

Contents?: true

Size: 562 Bytes

Versions: 5

Compression:

Stored size: 562 Bytes

Contents

# An Attachable can be attached to a Pod.
#
module Attachable extend Trait
  
  Detach = :detach
  
  attr_accessor :relative_position, :relative_rotation, :pod
  
  def detach
    pod.detach self
  end
  
  # Callback after detachment.
  #
  def detached; end
  #
  # after attachment
  #
  def attached
    self.relative_rotation = pod.rotation + self.rotation
  end
  
  # Move relative to the pod.
  #
  def move_relative
    self.position = pod.relative_position self
    self.rotation = pod.relative_rotation self unless self.kind_of? Turnable
  end
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gosu_extensions-0.3.8 lib/traits/attachable.rb
gosu_extensions-0.3.7 lib/traits/attachable.rb
gosu_extensions-0.3.6 lib/traits/attachable.rb
gosu_extensions-0.3.5 lib/traits/attachable.rb
gosu_extensions-0.3.4 lib/traits/attachable.rb