예제 #1
0
 /**
  * Ensures that the canvas image is at least the specified dimensions and cleared to all
  * transparent pixels. Also creates and adds the image layer to the parent layer if needed.
  */
 public void prepare(float width, float height) {
   // recreate our canvas if we need more room than we have (TODO: should we ever shrink it?)
   if (_image == null || _image.width() < width || _image.height() < height) {
     _image = PlayN.graphics().createImage(width, height);
     if (_layer != null) _layer.setImage(_image);
   } else {
     _image.canvas().clear();
   }
   if (_layer == null) {
     _layer = PlayN.graphics().createImageLayer(_image);
     if (_depth != null) _layer.setDepth(_depth);
     _parent.add(_layer);
   }
   _preparedWidth = width;
   _preparedHeight = height;
 }
예제 #2
0
  public Group createInterface() {
    Font fixedFont = PlayN.graphics().createFont("Fixed", Font.Style.PLAIN, 16);

    Slider slider;
    Label sliderValue;
    Group iface =
        new Group(AxisLayout.vertical().gap(15))
            .add(
                new Shim(15, 15),
                new Label("Click and drag the slider to change the value:"),
                slider = new Slider(0, -100, 100),
                sliderValue =
                    new Label("0")
                        .setConstraint(Constraints.minSize("-000"))
                        .setStyles(Style.HALIGN.right, Style.FONT.is(fixedFont)));
    slider.value.map(FORMATTER).connect(sliderValue.text.slot());
    return iface;
  }
예제 #3
0
 /**
  * Default constructor. <br>
  *
  * @param id
  * @param style
  * @param size
  */
 TextFont(String id, Style style, float size) {
   this.playNFont = PlayN.graphics().createFont(id, style, size);
 }