Sha256: ad0726b581c579df2a051f9c7928c0bce2d0e5bf12ce9fbbe18183561273f7b7

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

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_behaviors :layered
  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

4 entries across 4 versions & 1 rubygems

Version Path
gamebox-0.4.0.rc5 lib/gamebox/behaviors/graphical.rb
gamebox-0.4.0.rc4 lib/gamebox/behaviors/graphical.rb
gamebox-0.4.0.rc3 lib/gamebox/behaviors/graphical.rb
gamebox-0.4.0.rc2 lib/gamebox/behaviors/graphical.rb