Class: OR2D::Cameras::CenteredCamera
Overview
Instance Attribute Summary
Attributes inherited from OR2D::Camera
#target, #viewport
Instance Method Summary
collapse
#scroll_east, #scroll_north, #scroll_south, #scroll_west
Constructor Details
Returns a new instance of CenteredCamera.
3
4
5
6
7
8
|
# File 'lib/or2d/cameras/centered.rb', line 3
def initialize(target = nil)
super(OR2D.game.screen_width, OR2D.game.screen_height, target, 1.scale)
orientate
@scrolling = false
@direction = nil
end
|
Instance Method Details
35
36
37
|
# File 'lib/or2d/cameras/centered.rb', line 35
def reset_scrolling
@scrolling = false
end
|
24
25
26
27
28
|
# File 'lib/or2d/cameras/centered.rb', line 24
def scroll(direction, amount)
@scrolling = true
@direction = direction
@speed = amount
end
|
#update ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/or2d/cameras/centered.rb', line 10
def update
orientate
return unless @scrolling
case @direction
when :north then scroll_north(@speed, false)
when :south then scroll_south(@speed, false)
when :east then scroll_east(@speed, false)
when :west then scroll_west(@speed, false)
end
reset_scrolling
end
|