class Scar::Objects::Camera

Overview

A camera takes care of calling render() functions and drawing drawables.

A camera is essentially a wrapper around and SF::View. Its instance methods are delegated, so you can use them as normal instance methods. When drawing Entitys or Objects, their transforms are applied automatically.

Each space has a default camera, so there is no need to use this class explicitly in your application, except if you need custom views. See the CrSFML documentation for that.

Defined in:

scar/objects/camera.cr

Constructors

Instance Method Summary

Instance methods inherited from class Scar::Object

init(app : App, space : Space) init, initialized : Bool initialized, initialized=(initialized : Bool) initialized=, render(app : App, space : Space, dt) render, update(app : App, space : Space, dt) update

Instance methods inherited from class Scar::Entity

<<(c : Component)
<<(*cs : Component)
<<
, [](comp_type : T.class) : T forall T [], []?(comp_type : T.class) : T | Nil forall T []?, alive? : Bool alive?, components : Array(Scar::Component) components, components=(components : Array(Scar::Component)) components=, destroy destroy, has?(c : Component.class) : Bool
has?(cs : Array(Component.class)) : Bool
has?(*cs : Component.class) : Bool
has?
, id : String id, z : Int32 z, z=(z : Int32) z=

Constructor methods inherited from class Scar::Entity

new(id : String, components : Array(Component), *, position : Vec | Nil = nil, scale : Vec | Nil = nil, rotation : Float32 | Nil = nil, z : Int32 = 0)
new(id : String, *comps : Component, position : Vec | Nil = nil, scale : Vec | Nil = nil, rotation : Float32 | Nil = nil, z : Int32 = 0)
new(id : String, *, position : Vec | Nil = nil, scale : Vec | Nil = nil, rotation : Float32 | Nil = nil, z : Int32 = 0)
new

Constructor Detail

def self.new(id : String) #

[View source]

Instance Method Detail

def enabled : Bool #

Can be used to turn a camera off


[View source]
def enabled=(enabled : Bool) #

Can be used to turn a camera off


[View source]
def render_view(app, space, dt) #

This method is called by the render method of Spaces

It calls all render methods and draws all drawables onto the screen.


[View source]
def sf : SF::View #

The underlying SF::View


[View source]
def sf=(sf : SF::View) #

The underlying SF::View


[View source]