Class: Pixiurge::Display::Container
- Inherits:
-
Pixiurge::Displayable
- Object
- Pixiurge::Displayable
- Pixiurge::Display::Container
- Defined in:
- lib/pixiurge/displayable/container.rb
Overview
Sometimes it's useful to just have a container with one or more other Displayables inside. This allows both multiple Displayables without a custom type (e.g. a humanoid with a particle source attached) or to have multiple pieces with multiple transforms or animations (e.g. a shadow as a separate sprite that doesn't move up and down when the body jumps.)
Instance Attribute Summary collapse
- #contents ⇒ Object readonly
Attributes inherited from Pixiurge::Displayable
#block_height, #block_width, #displayable_type, #location_displayable, #location_name, #name, #position, #x, #y
Instance Method Summary collapse
-
#initialize(displayables, name:, engine_connector:) ⇒ Container
constructor
Constructor - create the container.
-
#messages_to_show_player(player) ⇒ Array
Messages to show this Displayable to a player.
Methods inherited from Pixiurge::Displayable
#destroy_for_player, #move_for_player, #show_to_player
Constructor Details
#initialize(displayables, name:, engine_connector:) ⇒ Container
Constructor - create the container
18 19 20 21 22 |
# File 'lib/pixiurge/displayable/container.rb', line 18 def initialize displayables, name:, engine_connector: @contents = displayables @displayable_type = "container" super(name: name, engine_connector: engine_connector) end |
Instance Attribute Details
#contents ⇒ Object (readonly)
10 11 12 |
# File 'lib/pixiurge/displayable/container.rb', line 10 def contents @contents end |
Instance Method Details
#messages_to_show_player(player) ⇒ Array
Messages to show this Displayable to a player.
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/pixiurge/displayable/container.rb', line 29 def (player) show_contents_msgs = @contents.map do |d| msgs = d.(player) msgs[0].merge!(name: d.name) msgs end = super [0].merge!({ "contents" => show_contents_msgs }) end |