Class Scale9Background

java.lang.Object
tripleplay.ui.Background
tripleplay.ui.bgs.Scale9Background

public class Scale9Background extends Background
A background constructed by scaling the parts of a source image to fit the target width and height. Uses Scale9.
  • Constructor Details

    • Scale9Background

      public Scale9Background(Tile tile)
      Creates a new background using the given texture. The texture is assumed to be divided into aa 3x3 grid of 9 equal pieces.
  • Method Details

    • scale9

      public Scale9 scale9()
      Returns the scale 9 instance for mutation. Be sure to finish mutation prior to binding.
    • xborder

      public Scale9Background xborder(float xborder)
      Sets the width of the left and right edges of the source axes to the given value. NOTE: xborder may be zero, to indicate that the source image has no left or right pieces, i.e. just three total pieces: top, bottom and center.
    • yborder

      public Scale9Background yborder(float yborder)
      Sets the height of the top and bottom edges of the source axes to the given value. NOTE: yborder may be zero, to indicate that the source image has no top or bottom pieces, i.e. just three pieces: left, right and center.
    • corners

      public Scale9Background corners(float size)
      Sets all edges of the source axes to the given value. Equivalent of calling xborder(border).yborder(border).
    • destScale

      public Scale9Background destScale(float scale)
      Sets an overall destination scale for the background. When instantiated, the target width and height are divided by this value, and when rendering the layer scale is multiplied by this value. This allows games to use high res images with smaller screen sizes.
    • setRepeatMode

      public void setRepeatMode(boolean repeat)
      Controls wether the the extended parts are scaled or repeated.
      Parameters:
      repeat - Repeats the extended parts if true otherwise scales them.
    • setTint

      public Scale9Background setTint(int tint)
      Sets the tint for this background, as ARGB.

      NOTE: this will overwrite any value configured via Background.alpha. Either include your desired alpha in the high bits of tint or set Background.alpha after calling this method.

      NOTE: the RGB components of a layer's tint only work on GL-based backends. It is not possible to tint layers using the HTML5 canvas and Flash backends.

    • setRepeatAlignment

      public void setRepeatAlignment(Style.HAlign horizontalAlignment)
      Defines how the repeated parts are aligned horizontally when the repeatMode is turned on. By default the repeated parts are aligned to the left border and left corners respectively.
      Parameters:
      horizontalAlignment - Only left or right alignment are supported.
    • setRepeatAlignment

      public void setRepeatAlignment(Style.VAlign verticalAlignment)
      Defines how the repeated parts are aligned vertically when the repeatMode is turned on. By default the repeated parts are aligned to the top border and top corners respectively.
      Parameters:
      verticalAlignment - Only top or bottom alignment are supported.