Class: ActorView

Inherits:
Object show all
Defined in:
lib/gamebox/core/actor_view.rb,
lib/gamebox/core/deprecated.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeActorView

Returns a new instance of ActorView.



7
8
9
10
11
12
13
14
15
16
# File 'lib/gamebox/core/actor_view.rb', line 7

def initialize
  @layer = actor.do_or_do_not(:layer) || 0
  @parallax = actor.do_or_do_not(:parallax) || 1

  # TODO clean up the show/hide here make nice with visible behavior?
  actor.when :remove_me do unregister  end
  actor.when :hide_me   do unregister  end
  actor.when :show_me   do register    end
  
end

Instance Attribute Details

#layerObject

Returns the value of attribute layer.



6
7
8
# File 'lib/gamebox/core/actor_view.rb', line 6

def layer
  @layer
end

#parallaxObject

Returns the value of attribute parallax.



6
7
8
# File 'lib/gamebox/core/actor_view.rb', line 6

def parallax
  @parallax
end

Class Method Details

.define(actor_view_type, &blk) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/gamebox/core/actor_view.rb', line 35

def define(actor_view_type, &blk)
  @definitions ||= {}
  definition = ActorViewDefinition.new
  definition.source = caller.detect{|c|!c.match /core/}
  definition.instance_eval &blk if block_given?
  @definitions[actor_view_type] = definition
end

.definitionsObject



43
44
45
# File 'lib/gamebox/core/actor_view.rb', line 43

def definitions
  @definitions ||= {}
end

.inherited(klass) ⇒ Object



12
13
14
# File 'lib/gamebox/core/deprecated.rb', line 12

def self.inherited(klass)
  log "Cannot extend #{self} anymore #{klass}"
end

Instance Method Details

#registerObject



18
19
20
# File 'lib/gamebox/core/actor_view.rb', line 18

def register
  renderer.register_drawable self
end

#screen_heightObject



30
31
32
# File 'lib/gamebox/core/actor_view.rb', line 30

def screen_height
  @screen_height ||= wrapped_screen.height
end

#screen_widthObject



26
27
28
# File 'lib/gamebox/core/actor_view.rb', line 26

def screen_width
  @screen_width ||= wrapped_screen.width
end

#unregisterObject



22
23
24
# File 'lib/gamebox/core/actor_view.rb', line 22

def unregister
  renderer.unregister_drawable self
end