class Scar::Components::Tilemap

Overview

This component provides a simple way to draw a Tiled tilemap.

It only supports ungrouped TileLayers (finite or infinite) with an embedded Tileset referencing an image whose path is corresponds to a loaded texture asset (see Assets)

This component does not support:

This component is intended as an easy way to draw tilemaps for prototyping and as an example of how you could implement the drawing of a tilemap youself. You can use it in more mature applications as well of course.

Defined in:

scar/components/tilemap.cr

Constructors

Instance Method Summary

Instance methods inherited from module Scar::Drawable

blend_mode : SF::BlendMode blend_mode, blend_mode=(blend_mode : SF::BlendMode) blend_mode=, drawable : SF::Drawable drawable, shader : SF::Shader shader, shader=(shader : SF::Shader) shader=, texture : SF::Texture texture, texture=(texture : SF::Texture) texture=, visible=(visible) visible=, visible? visible?

Constructor Detail

def self.new(asset_id : String) #

Creates a new tilemap component by loading a tilemap from Assets. This function also enables hot-reloading of the tilemap (if it is enabled in the App of course)


[View source]
def self.new(map : Scar::Tiled::Map) #

Creates a new tilemap component with the given Scar::Tiled::Map


[View source]

Instance Method Detail

def drawable : SF::VertexBuffer #

Returns the SF::VertexBuffer that is used to draw the tilemap


[View source]
def map : Scar::Tiled::Map #

Returns the underlying Scar::Tiled::Map


[View source]
def map=(new_map : Scar::Tiled::Map) #

Replaces the underlying Scar::Tiled::Map


[View source]
def update_buffer #

Rebuilds the SF::VertexBuffer used to draw the tilemap


[View source]