Class: Pixiurge::Display::TextEffect

Inherits:
Pixiurge::Displayable show all
Defined in:
lib/pixiurge/displayable/text_effect.rb

Overview

This is for a text "effect" - that is, text that exists for a short time and then disappears, a bit like a particle.

Since:

  • 0.1.0

Instance Attribute Summary

Attributes inherited from Pixiurge::Displayable

#block_height, #block_width, #displayable_type, #location_displayable, #location_name, #name, #position, #x, #y

Instance Method Summary collapse

Methods inherited from Pixiurge::Displayable

#destroy_for_player, #move_for_player, #show_to_player

Constructor Details

#initialize(text, style: { fill: "yellow", fontSize: "20pt", wordwrap: false, wordWrapWidth: 100 }, final_properties: { y: "-20", alpha: 0.1 }, duration: 5000, name:, engine_connector:) ⇒ TextEffect

Constructor - create the text effect object

Parameters:

  • text (String)

    The text to display

  • style (Hash)

    Text-style properties for how to display it; see "http://pixijs.download/dev/docs/PIXI.TextStyle.html".

  • name (String)

    The Demiurge item name for this Displayable, or the empty string for no given name; unnamed Displayables can only be manually cleared by DestroyAllDisplayables

  • duration (Integer)

    The duration to display the text, in milliseconds; default: 5000

  • final_properties (Hash)

    Final property values after tweening; by default the text will rise (-y coord) and fade (0.1 alpha)

  • engine_connector (Pixiurge::EngineConnector)

    The Pixiurge EngineConnector this Displayable belongs to

Since:

  • 0.1.0



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/pixiurge/displayable/text_effect.rb', line 15

def initialize text,
  style: { fill: "yellow", fontSize: "20pt", wordwrap: false, wordWrapWidth: 100 },
  final_properties: { y: "-20", alpha: 0.1 },
  duration: 5000,
  name:, engine_connector:
  @text = text
  @style = style
  @final_properties = final_properties
  @duration = duration
  @displayable_type = "text_effect"
  super(name: name, engine_connector: engine_connector)
end

Instance Method Details

#messages_to_show_player(player) ⇒ Array

Messages to show this Displayable to a player.

Parameters:

Returns:

  • (Array)

    Messages to show this container to the player

Since:

  • 0.1.0



33
34
35
36
37
# File 'lib/pixiurge/displayable/text_effect.rb', line 33

def messages_to_show_player(player)
  messages = super
  messages[0].merge!({ "text" => @text, "style" => @style, "duration" => 5000, "finalProperties" => @final_properties })
  messages
end