Class: Camera2D

Inherits:
Object
  • Object
show all
Defined in:
mrb_doc/models/camera2d.rb

Overview

Camera2D is used for simply moving a viewport around.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(offset, target, rotation, zoom) ⇒ Camera2D

Creates a new instance of Camera2D

Parameters:



15
16
17
18
19
# File 'mrb_doc/models/camera2d.rb', line 15

def initialize(offset, target, rotation, zoom)
  # mrb_Camera2D_initialize
  # src/mruby_integration/models/camera2d.cpp
  Camera2D.new
end

Instance Attribute Details

#offsetVector2

Returns:



4
5
6
# File 'mrb_doc/models/camera2d.rb', line 4

def offset
  @offset
end

#rotationFloat

Returns:

  • (Float)


7
8
9
# File 'mrb_doc/models/camera2d.rb', line 7

def rotation
  @rotation
end

#targetVector2

Returns:



4
5
6
# File 'mrb_doc/models/camera2d.rb', line 4

def target
  @target
end

#zoomFloat

Returns:

  • (Float)


7
8
9
# File 'mrb_doc/models/camera2d.rb', line 7

def zoom
  @zoom
end

Instance Method Details

#as_in_viewport(vector) ⇒ Vector2

Pass in a vector with world coordinates to see what that translates to in the camera’s viewport.

Parameters:

Returns:



69
70
71
72
# File 'mrb_doc/models/camera2d.rb', line 69

def as_in_viewport(vector)
  # src/mruby_integration/models/camera2d.cpp
  Vector2.new
end

#as_in_world(vector) ⇒ Vector2

Pass in a vector with camera viewport coordinates to see what that translates to in the world.

Parameters:

Returns:



78
79
80
81
# File 'mrb_doc/models/camera2d.rb', line 78

def as_in_world(vector)
  # src/mruby_integration/models/camera2d.cpp
  Vector2.new
end

#drawing { ... } ⇒ nil

Draws the world through the lens of the camera

Yields:

  • The block that calls your rendering logic

Returns:

  • (nil)


60
61
62
63
# File 'mrb_doc/models/camera2d.rb', line 60

def drawing(&block)
  # src/mruby_integration/models/camera2d.cpp
  nil
end

#to_hHash

Return the object represented by a Hash

Returns:

  • (Hash)


47
48
49
50
51
52
53
54
55
# File 'mrb_doc/models/camera2d.rb', line 47

def to_h
  # src/mruby_integration/models/camera2d.cpp
  {
    offset: offset.to_h,
    target: target.to_h,
    rotation: rotation,
    zoom: zoom,
  }
end