Sha256: f3420c007f087cf1c7514d76a2edb9b2e8b966f3571cae7bc178553ed5089cc6

Contents?: true

Size: 727 Bytes

Versions: 5

Compression:

Stored size: 727 Bytes

Contents

# Ruby2D::Renderable

module Ruby2D
  module Renderable

    attr_reader :x, :y, :z, :width, :height, :color

    # Set the z position (depth) of the object
    def z=(z)
      remove
      @z = z
      add
    end

    # Add the object to the window
    def add
      Window.add(self)
    end

    # Remove the object from the window
    def remove
      Window.remove(self)
    end

    # Set the color value
    def color=(c)
      @color = Color.new(c)
    end

    # Allow British English spelling of color
    alias_method :colour, :color
    alias_method :colour=, :color=

    # Add a contains method stub
    def contains?(x, y)
      x >= @x && x <= (@x + @width) && y >= @y && y <= (@y + @height)
    end

  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
ruby2d-0.11.3 lib/ruby2d/renderable.rb
ruby2d-0.11.2 lib/ruby2d/renderable.rb
ruby2d-rpeck-windows-0.11.1 lib/ruby2d/renderable.rb
ruby2d-0.11.1 lib/ruby2d/renderable.rb
ruby2d-0.11.0 lib/ruby2d/renderable.rb