Package com.esotericsoftware.spine.attachments

Examples of com.esotericsoftware.spine.attachments.RegionAttachment


    boolean additive = false;
    for (int i = 0, n = drawOrder.size; i < n; i++) {
      Slot slot = drawOrder.get(i);
      Attachment attachment = slot.attachment;
      if (attachment instanceof RegionAttachment) {
        RegionAttachment regionAttachment = (RegionAttachment)attachment;
        regionAttachment.updateVertices(slot);
        float[] vertices = regionAttachment.getVertices();
        if (slot.data.getAdditiveBlending() != additive) {
          additive = !additive;
          if (additive)
            batch.setBlendFunction(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
          else
            batch.setBlendFunction(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        }
        batch.draw(regionAttachment.getRegion().getTexture(), vertices, 0, vertices.length);
      }
    }
    if (additive) batch.setBlendFunction(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
  }
View Full Code Here


      regionSequenceAttachment.setFrameTime(1 / input.readFloat());
      regionSequenceAttachment.setMode(Mode.values()[input.readInt(true)]);
    }

    if (attachment instanceof RegionAttachment) {
      RegionAttachment regionAttachment = (RegionAttachment)attachment;
      regionAttachment.setX(input.readFloat() * scale);
      regionAttachment.setY(input.readFloat() * scale);
      regionAttachment.setScaleX(input.readFloat());
      regionAttachment.setScaleY(input.readFloat());
      regionAttachment.setRotation(input.readFloat());
      regionAttachment.setWidth(input.readFloat() * scale);
      regionAttachment.setHeight(input.readFloat() * scale);
      regionAttachment.updateOffset();
    }

    return attachment;
  }
View Full Code Here

      String modeString = map.getString("mode");
      regionSequenceAttachment.setMode(modeString == null ? Mode.forward : Mode.valueOf(modeString));
    }

    if (attachment instanceof RegionAttachment) {
      RegionAttachment regionAttachment = (RegionAttachment)attachment;
      regionAttachment.setX(map.getFloat("x", 0) * scale);
      regionAttachment.setY(map.getFloat("y", 0) * scale);
      regionAttachment.setScaleX(map.getFloat("scaleX", 1));
      regionAttachment.setScaleY(map.getFloat("scaleY", 1));
      regionAttachment.setRotation(map.getFloat("rotation", 0));
      regionAttachment.setWidth(map.getFloat("width", 32) * scale);
      regionAttachment.setHeight(map.getFloat("height", 32) * scale);
      regionAttachment.updateOffset();
    }

    return attachment;
  }
View Full Code Here

    Array<Slot> slots = skeleton.getSlots();
    for (int i = 0, n = slots.size; i < n; i++) {
      Slot slot = slots.get(i);
      Attachment attachment = slot.attachment;
      if (attachment instanceof RegionAttachment) {
        RegionAttachment regionAttachment = (RegionAttachment)attachment;
        regionAttachment.updateVertices(slot);
        float[] vertices = regionAttachment.getVertices();
        renderer.line(vertices[X1], vertices[Y1], vertices[X2], vertices[Y2]);
        renderer.line(vertices[X2], vertices[Y2], vertices[X3], vertices[Y3]);
        renderer.line(vertices[X3], vertices[Y3], vertices[X4], vertices[Y4]);
        renderer.line(vertices[X4], vertices[Y4], vertices[X1], vertices[Y1]);
      }
View Full Code Here

    for (int i = 0, n = drawOrder.size; i < n; i++) {
      Slot slot = drawOrder.get(i);
      Attachment attachment = slot.attachment;
      Texture texture = null;
      if (attachment instanceof RegionAttachment) {
        RegionAttachment region = (RegionAttachment)attachment;
        region.updateWorldVertices(slot, premultipliedAlpha);
        vertices = region.getWorldVertices();
        triangles = quadTriangles;
        texture = region.getRegion().getTexture();

      } else if (attachment instanceof MeshAttachment) {
        MeshAttachment mesh = (MeshAttachment)attachment;
        mesh.updateWorldVertices(slot, true);
        vertices = mesh.getWorldVertices();
View Full Code Here

    Array<Slot> drawOrder = skeleton.drawOrder;
    for (int i = 0, n = drawOrder.size; i < n; i++) {
      Slot slot = drawOrder.get(i);
      Attachment attachment = slot.attachment;
      if (attachment instanceof RegionAttachment) {
        RegionAttachment regionAttachment = (RegionAttachment)attachment;
        regionAttachment.updateWorldVertices(slot, premultipliedAlpha);
        float[] vertices = regionAttachment.getWorldVertices();
        if (slot.data.getAdditiveBlending() != additive) {
          additive = !additive;
          if (additive)
            batch.setBlendFunction(srcFunc, GL20.GL_ONE);
          else
            batch.setBlendFunction(srcFunc, GL20.GL_ONE_MINUS_SRC_ALPHA);
        }
        batch.draw(regionAttachment.getRegion().getTexture(), vertices, 0, 20);
      } else if (attachment instanceof MeshAttachment || attachment instanceof SkinnedMeshAttachment) {
        throw new RuntimeException("PolygonSpriteBatch is required to render meshes.");
      } else if (attachment instanceof SkeletonAttachment) {
        Skeleton attachmentSkeleton = ((SkeletonAttachment)attachment).getSkeleton();
        if (attachmentSkeleton == null) continue;
View Full Code Here

    switch (AttachmentType.values()[input.readByte()]) {
    case region: {
      String path = input.readString();
      if (path == null) path = name;
      RegionAttachment region = attachmentLoader.newRegionAttachment(skin, name, path);
      if (region == null) return null;
      region.setPath(path);
      region.setX(input.readFloat() * scale);
      region.setY(input.readFloat() * scale);
      region.setScaleX(input.readFloat());
      region.setScaleY(input.readFloat());
      region.setRotation(input.readFloat());
      region.setWidth(input.readFloat() * scale);
      region.setHeight(input.readFloat() * scale);
      Color.rgba8888ToColor(region.getColor(), input.readInt());
      region.updateOffset();
      return region;
    }
    case boundingbox: {
      BoundingBoxAttachment box = attachmentLoader.newBoundingBoxAttachment(skin, name);
      if (box == null) return null;
View Full Code Here

    name = map.getString("name", name);
    String path = map.getString("path", name);

    switch (AttachmentType.valueOf(map.getString("type", AttachmentType.region.name()))) {
    case region: {
      RegionAttachment region = attachmentLoader.newRegionAttachment(skin, name, path);
      if (region == null) return null;
      region.setPath(path);
      region.setX(map.getFloat("x", 0) * scale);
      region.setY(map.getFloat("y", 0) * scale);
      region.setScaleX(map.getFloat("scaleX", 1));
      region.setScaleY(map.getFloat("scaleY", 1));
      region.setRotation(map.getFloat("rotation", 0));
      region.setWidth(map.getFloat("width") * scale);
      region.setHeight(map.getFloat("height") * scale);

      String color = map.getString("color", null);
      if (color != null) region.getColor().set(Color.valueOf(color));

      region.updateOffset();
      return region;
    }
    case boundingbox: {
      BoundingBoxAttachment box = attachmentLoader.newBoundingBoxAttachment(skin, name);
      if (box == null) return null;
View Full Code Here

      Array<Slot> slots = skeleton.getSlots();
      for (int i = 0, n = slots.size; i < n; i++) {
        Slot slot = slots.get(i);
        Attachment attachment = slot.attachment;
        if (attachment instanceof RegionAttachment) {
          RegionAttachment regionAttachment = (RegionAttachment)attachment;
          regionAttachment.updateWorldVertices(slot, false);
          float[] vertices = regionAttachment.getWorldVertices();
          shapes.line(vertices[X1], vertices[Y1], vertices[X2], vertices[Y2]);
          shapes.line(vertices[X2], vertices[Y2], vertices[X3], vertices[Y3]);
          shapes.line(vertices[X3], vertices[Y3], vertices[X4], vertices[Y4]);
          shapes.line(vertices[X4], vertices[Y4], vertices[X1], vertices[Y1]);
        }
View Full Code Here

TOP

Related Classes of com.esotericsoftware.spine.attachments.RegionAttachment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.