Class: ActorViewDefinition
- Defined in:
- lib/gamebox/core/actor_view_definition.rb
Instance Attribute Summary collapse
-
#draw_block ⇒ Object
Returns the value of attribute draw_block.
-
#helpers_block ⇒ Object
Returns the value of attribute helpers_block.
-
#required_injections ⇒ Object
Returns the value of attribute required_injections.
-
#setup_block ⇒ Object
Returns the value of attribute setup_block.
-
#source ⇒ Object
Returns the value of attribute source.
Instance Method Summary collapse
-
#draw(&draw_block) ⇒ Object
Draw callback that is called when the view needs to draw.
-
#helpers(&helper_block) ⇒ Object
Define methods and include modules for use by your view.
-
#requires(*injections_needed) ⇒ Object
Sets the dependencies for this ActorView.
-
#setup(&setup_block) ⇒ Object
Setup callback that is called when the view is constructed.
Instance Attribute Details
#draw_block ⇒ Object
Returns the value of attribute draw_block.
2 3 4 |
# File 'lib/gamebox/core/actor_view_definition.rb', line 2 def draw_block @draw_block end |
#helpers_block ⇒ Object
Returns the value of attribute helpers_block.
2 3 4 |
# File 'lib/gamebox/core/actor_view_definition.rb', line 2 def helpers_block @helpers_block end |
#required_injections ⇒ Object
Returns the value of attribute required_injections.
2 3 4 |
# File 'lib/gamebox/core/actor_view_definition.rb', line 2 def required_injections @required_injections end |
#setup_block ⇒ Object
Returns the value of attribute setup_block.
2 3 4 |
# File 'lib/gamebox/core/actor_view_definition.rb', line 2 def setup_block @setup_block end |
#source ⇒ Object
Returns the value of attribute source.
2 3 4 |
# File 'lib/gamebox/core/actor_view_definition.rb', line 2 def source @source end |
Instance Method Details
#draw(&draw_block) ⇒ Object
Draw callback that is called when the view needs to draw.
draw do |screen, x_offset, y_offset, z|
...
end
31 32 33 |
# File 'lib/gamebox/core/actor_view_definition.rb', line 31 def draw(&draw_block) @draw_block = draw_block end |
#helpers(&helper_block) ⇒ Object
Define methods and include modules for use by your view.
helpers do
include MyHelper
def do_some_view_calc
...
end
end
43 44 45 |
# File 'lib/gamebox/core/actor_view_definition.rb', line 43 def helpers(&helper_block) @helpers_block = helper_block end |
#requires(*injections_needed) ⇒ Object
Sets the dependencies for this ActorView.
These will be pulled from the Actor’s object context at view construction time.
requires :resource_manager
10 11 12 |
# File 'lib/gamebox/core/actor_view_definition.rb', line 10 def requires(*injections_needed) @required_injections = injections_needed end |
#setup(&setup_block) ⇒ Object
Setup callback that is called when the view is constructed. The actor will be set before your setup block is executed.
setup do
resource_manager.load_image('something.png')
end
21 22 23 |
# File 'lib/gamebox/core/actor_view_definition.rb', line 21 def setup(&setup_block) @setup_block = setup_block end |