Sha256: 8839d6831fc36149ac91e95094a2d71be2c5b6e007dee4f9fb4bf02f9004c1a9

Contents?: true

Size: 735 Bytes

Versions: 6

Compression:

Stored size: 735 Bytes

Contents

module Dedalus
  module Elements
    class Sprite < Image
      attr_accessor :asset_width, :asset_height, :frame

      def asset
        @asset ||= Dedalus::ImageRepository.lookup_tiles(path, asset_width, asset_height)[frame]
      end

      def scale
        @scale ||= 1.0
      end

      def width
        2*padding + (asset_width * scale)
      end

      def height
        2*padding + (asset_height * scale)
      end

      def self.example_data
        {
          path: "media/images/tiles.png",
          frame: 3,
          asset_width: 64,
          asset_height: 64,
          invert_x: true,
          scale: 2.5
        }
      end

      def self.description
        "an animated image"
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dedalus-0.2.21 lib/dedalus/elements/sprite.rb
dedalus-0.2.20 lib/dedalus/elements/sprite.rb
dedalus-0.2.19 lib/dedalus/elements/sprite.rb
dedalus-0.2.18 lib/dedalus/elements/sprite.rb
dedalus-0.2.17 lib/dedalus/elements/sprite.rb
dedalus-0.2.16 lib/dedalus/elements/sprite.rb