Class: RedBird::Entity
- Inherits:
-
Object
- Object
- RedBird::Entity
- Defined in:
- lib/red_bird/entity.rb
Overview
An entity is an object that is managed by the Engine; it has a size, a position, ticks, and is renderable. RedBird::Engine.run expects every single entity that it receives from Stage to have these methods and attributes.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#height ⇒ Integer
readonly
Size.
-
#pos_x ⇒ Integer
readonly
Position.
-
#pos_y ⇒ Integer
readonly
Position.
-
#priority ⇒ Integer
readonly
Entities with higher priorit are called first when the RedBird::Engine.run calls #tick and #render.
-
#width ⇒ Integer
readonly
Size.
Instance Method Summary collapse
-
#cursor_down(x, y) ⇒ Object
The RedBird::Engine.run calls this method whenever there is a click over this entity.
-
#cursor_hover(x, y) ⇒ Object
The RedBird::Engine.run calls this method whenever the cursor is over this entity.
-
#cursor_up(x, y) ⇒ Object
The RedBird::Engine.run calls this method whenever there is a cursor release over this entity.
-
#render ⇒ Object
The RedBird::Engine.run calls this method to render this entity into the scree.
-
#tick ⇒ Object
The RedBird::Engine.run calls this method every single frame.
Instance Attribute Details
#height ⇒ Integer (readonly)
Size
17 18 19 |
# File 'lib/red_bird/entity.rb', line 17 def height @height end |
#pos_x ⇒ Integer (readonly)
Position
13 14 15 |
# File 'lib/red_bird/entity.rb', line 13 def pos_x @pos_x end |
#pos_y ⇒ Integer (readonly)
Position
13 14 15 |
# File 'lib/red_bird/entity.rb', line 13 def pos_y @pos_y end |
#priority ⇒ Integer (readonly)
Entities with higher priorit are called first when the RedBird::Engine.run calls #tick and #render.
22 23 24 |
# File 'lib/red_bird/entity.rb', line 22 def priority @priority end |
#width ⇒ Integer (readonly)
Size
17 18 19 |
# File 'lib/red_bird/entity.rb', line 17 def width @width end |
Instance Method Details
#cursor_down(x, y) ⇒ Object
The RedBird::Engine.run calls this method whenever there is a click over this entity. Overwrite this function if you want your entity to react to a click.
50 51 52 |
# File 'lib/red_bird/entity.rb', line 50 def cursor_down(x, y) # By default do nothing end |
#cursor_hover(x, y) ⇒ Object
The RedBird::Engine.run calls this method whenever the cursor is over this entity. Overwrite this function if you want your entity to react to a cursor hover.
39 40 41 |
# File 'lib/red_bird/entity.rb', line 39 def cursor_hover(x, y) # By default do nothing end |
#cursor_up(x, y) ⇒ Object
The RedBird::Engine.run calls this method whenever there is a cursor release over this entity. Overwrite this function if you want your entity to react to a cursor release.
61 62 63 |
# File 'lib/red_bird/entity.rb', line 61 def cursor_up(x, y) # By default do nothing end |
#render ⇒ Object
The RedBird::Engine.run calls this method to render this entity into the scree. Overwrite this method if you want to change how the entity renders into the screen.
70 71 72 |
# File 'lib/red_bird/entity.rb', line 70 def render self.current_sprite.render_to_screen(self.pos_x, self.pos_y) end |
#tick ⇒ Object
The RedBird::Engine.run calls this method every single frame. Overwrite it if you want your entity to do something every frame.
28 29 30 |
# File 'lib/red_bird/entity.rb', line 28 def tick # By default do nothing end |