Class: RGame::Engine::CameraView

Inherits:
Node2D
  • Object
show all
Defined in:
lib/rgame/engine/camera_view.rb

Overview

A node whose children live in world space and are drawn through a Camera: it wraps their draw in renderer.translated(-camera.x, -camera.y), so the camera's offset maps the world onto the screen. The children never know about the camera — they draw at their own absolute (world) origin, and the view transform does the rest. The owning scene drives the camera (e.g. centring it on the player); this node only applies it.

The offset is a draw-time transform, not a position baked into a node, so the same world can later be drawn through several cameras (split-screen) by repeating the pass under different offsets/clips.

Instance Attribute Summary

Attributes inherited from Node2D

#abs_angle, #abs_x, #abs_y, #abs_z, #angle, #children, #components, #context, #height, #parent, #scene, #width, #x, #y, #z

Instance Method Summary collapse

Methods inherited from Node2D

#add_component, #add_node, #control, #draw, #enter_tree, #exit_tree, #freed?, #get_component, #in_tree?, #on_add, #on_control, #on_draw, #on_remove, #on_update, #queue_free, #remove_component, #remove_node, #root, #sweep_freed, #system, #update

Methods included from Signal::DSL

#signal

Constructor Details

#initialize(camera:) ⇒ CameraView

Returns a new instance of CameraView.



16
17
18
19
# File 'lib/rgame/engine/camera_view.rb', line 16

def initialize(camera:, **)
  super(**)
  @camera = camera
end