Class: RedBird::RelativeEntity
- Inherits:
-
Entity
- Object
- Entity
- RedBird::RelativeEntity
show all
- Defined in:
- lib/red_bird/relative_entity.rb
Overview
The Entity has an absolute position on the screen. Use this class if you want an entity that has a position relative to a scenario (TileMap).
Instance Attribute Summary collapse
Attributes inherited from Entity
#priority
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Entity
#cursor_down, #cursor_hover, #cursor_up, #render, #tick
Constructor Details
#initialize(relative_pos_x, relative_pos_y, width, height) ⇒ RelativeEntity
19
20
21
22
23
24
25
26
|
# File 'lib/red_bird/relative_entity.rb', line 19
def initialize(relative_pos_x, relative_pos_y, width, height)
super()
@priority = 1
@collision_box = RedBird::Rect.new(
relative_pos_x, relative_pos_y, width, height)
end
|
Instance Attribute Details
12
13
14
|
# File 'lib/red_bird/relative_entity.rb', line 12
def collision_box
@collision_box
end
|
Class Method Details
39
40
41
|
# File 'lib/red_bird/relative_entity.rb', line 39
def self.scenario
return @@scenario
end
|
.scenario=(scenario) ⇒ Object
33
34
35
|
# File 'lib/red_bird/relative_entity.rb', line 33
def self.scenario=(scenario)
@@scenario = scenario
end
|
Instance Method Details
#height ⇒ Integer
91
92
93
|
# File 'lib/red_bird/relative_entity.rb', line 91
def height
@collision_box.height
end
|
#pos_x ⇒ Float
Gets absolute position (position in the screen).
71
72
73
|
# File 'lib/red_bird/relative_entity.rb', line 71
def pos_x
@collision_box.x - @@scenario.hor_offset + @@scenario.pos_x
end
|
#pos_y ⇒ Float
Gets absolute position (position in the screen).
79
80
81
|
# File 'lib/red_bird/relative_entity.rb', line 79
def pos_y
@collision_box.y - @@scenario.ver_offset + @@scenario.pos_y
end
|
#relative_pos_x ⇒ Integer
45
46
47
|
# File 'lib/red_bird/relative_entity.rb', line 45
def relative_pos_x
return @collision_box.x
end
|
#relative_pos_x=(x) ⇒ Object
57
58
59
|
# File 'lib/red_bird/relative_entity.rb', line 57
def relative_pos_x=(x)
@collision_box.x = x
end
|
#relative_pos_y ⇒ Integer
51
52
53
|
# File 'lib/red_bird/relative_entity.rb', line 51
def relative_pos_y
return @collision_box.y
end
|
#relative_pos_y=(y) ⇒ Object
63
64
65
|
# File 'lib/red_bird/relative_entity.rb', line 63
def relative_pos_y=(y)
@collision_box.y = y
end
|
#width ⇒ Integer
85
86
87
|
# File 'lib/red_bird/relative_entity.rb', line 85
def width
@collision_box.width
end
|