Class Text

java.lang.Object
ch.epfl.cs107.play.engine.actor.Entity
ch.epfl.cs107.play.engine.actor.Text
All Implemented Interfaces:
Acoustics, Actor, Graphics, Updatable, Positionable

public class Text extends Entity
Text entity, can be used as actor and put and aligned inside a cell .
  • Constructor Details

    • Text

      public Text(String text, DiscreteCoordinates position, Area area, boolean isScreenRelative, float fontSize, Color color, boolean bold, boolean italics, TextAlign.Horizontal hAlign, TextAlign.Vertical vAlign, float alpha, float depth)
      Default Text constructor
      Parameters:
      text - (String): String of the text, not null
      position - (DiscreteCoordinates): Initial position in the grid, not null
      area - (Area): Area context of the text, not null
      isScreenRelative - (boolean): indicate if the text is relative to the world or the window
      fontSize - (float): the font size (i.e. 1 is one cell high)
      color - (Color): Color of the text, not null
      bold - (boolean): Is the text bold
      italics - (boolean): Is the text italics
      hAlign - (Horizontal): Which horizontal alignment has the text, not null
      vAlign - (Vertical): Which vertical alignment has the text, not null
      alpha - (float): transparency of the text (0 is full invisible and 1 is full opaque)
      depth - (float): the depth of the text, small depth draw first
    • Text

      public Text(String text, DiscreteCoordinates position, Area area, boolean isScreenRelative, float fontSize, Color color, boolean bold, boolean italics)
      Alternative Text constructor
      Parameters:
      text - (String): String of the text, not null
      position - (DiscreteCoordinates): Initial position in the grid, not null
      area - (Area): Area context of the text, not null
      isScreenRelative - (boolean): indicate if the text is relative to the world or the window
      fontSize - (float): the font size (i.e. 1 is one cell high)
      color - (Color): Color of the text, not null
      bold - (boolean): Is the text bold
      italics - (boolean): Is the text italics
    • Text

      public Text(String text, DiscreteCoordinates position, Area area, boolean isScreenRelative, float fontSize, Color color, float alpha, float depth)
      Alternative Text constructor
      Parameters:
      text - (String): String of the text, not null
      position - (DiscreteCoordinates): Initial position in the grid, not null
      area - (Area): Area context of the text, not null
      isScreenRelative - (boolean): indicate if the text is relative to the world or the window
      fontSize - (float): the font size (i.e. 1 is one cell high)
      color - (Color): Color of the text, not null
      alpha - (float): transparency of the text (0 is full invisible and 1 is full opaque)
      depth - (float): the depth of the text, small depth draw first
    • Text

      public Text(String text, DiscreteCoordinates position, Area area, boolean isScreenRelative, float fontSize, Color color)
      Alternative Text constructor
      Parameters:
      text - (String): String of the text, not null
      position - (DiscreteCoordinates): Initial position in the grid, not null
      area - (Area): Area context of the text, not null
      isScreenRelative - (boolean): indicate if the text is relative to the world or the window
      fontSize - (float): the font size (i.e. 1 is one cell high)
      color - (Color): Color of the text, not null
  • Method Details

    • setText

      public void setText(String text)
      Update the text displayed
      Parameters:
      text - (String) the new text, not null
    • makeItAppear

      public void makeItAppear(float stepSize)
      Make the text appear by step of given size
      Parameters:
      stepSize - (float): the step size
    • makeItDisappear

      public void makeItDisappear(float stepSize)
      Make the text disappear by step of given size
      Parameters:
      stepSize - (float): the step size
    • update

      public void update(float deltaTime)
      Description copied from interface: Updatable
      Simulates a single time step. Note: Need to be Override
      Parameters:
      deltaTime - elapsed time since last update, in seconds, non-negative
    • draw

      public void draw(Canvas canvas)
      Description copied from interface: Graphics
      Renders itself on specified canvas.
      Parameters:
      canvas - target, not null