Sha256: 61b4adb2a123c8aa51c187cac8a094a22de58020672e75525a488e21e530c9b6

Contents?: true

Size: 1000 Bytes

Versions: 1

Compression:

Stored size: 1000 Bytes

Contents

# keeps track of an image for you based on the actor's class
# by default it expects images to be:
# data/graphics/classname.png
Behavior.define :graphical do

  requires :resource_manager
  setup do 
    image = resource_manager.load_actor_image(actor)
    scale = @opts[:scale] || 1,
    actor.has_attributes( image: image,
                          width: image.width,
                          height: image.height,
                          tiled: @opts[:tiled],
                          view: @opts[:view] || :graphical_actor_view,
                          num_x_tiles: @opts[:num_x_tiles] || 1,
                          num_y_tiles: @opts[:num_y_tiles] || 1,
                          scale: scale,
                          x_scale: @opts[:x_scale] || scale,
                          y_scale: @opts[:y_scale] || scale,
                          rotation: 0.0 )

    actor.when :image_changed do |old, new|
      actor.width = new.width
      actor.height = new.height
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gamebox-0.4.0.rc1 lib/gamebox/behaviors/graphical.rb