Package com.esotericsoftware.spine.attachments

Examples of com.esotericsoftware.spine.attachments.Attachment


    BoneData boneData = new BoneData("bone", null);
    skeletonData.getBones().add(boneData);

    skeletonData.getSlots().add(new SlotData("slot", boneData));

    Attachment attachment1 = new Attachment("attachment1") {};
    Attachment attachment2 = new Attachment("attachment2") {};

    Skin skin = new Skin("skin");
    skin.addAttachment(0, "attachment1", attachment1);
    skin.addAttachment(0, "attachment2", attachment2);
    skeletonData.setDefaultSkin(skin);
View Full Code Here


  void attachAll (Skeleton skeleton, Skin oldSkin) {
    for (Entry<Key, Attachment> entry : oldSkin.attachments.entries()) {
      int slotIndex = entry.key.slotIndex;
      Slot slot = skeleton.slots.get(slotIndex);
      if (slot.attachment == entry.value) {
        Attachment attachment = getAttachment(slotIndex, entry.key.name);
        if (attachment != null) slot.setAttachment(attachment);
      }
    }
  }
View Full Code Here

        Array<Slot> slots = this.slots;
        for (int i = 0, n = slots.size; i < n; i++) {
          Slot slot = slots.get(i);
          String name = slot.data.attachmentName;
          if (name != null) {
            Attachment attachment = newSkin.getAttachment(i, name);
            if (attachment != null) slot.setAttachment(attachment);
          }
        }
      }
    }
View Full Code Here

  /** @return May be null. */
  public Attachment getAttachment (int slotIndex, String attachmentName) {
    if (attachmentName == null) throw new IllegalArgumentException("attachmentName cannot be null.");
    if (skin != null) {
      Attachment attachment = skin.getAttachment(slotIndex, attachmentName);
      if (attachment != null) return attachment;
    }
    if (data.defaultSkin != null) return data.defaultSkin.getAttachment(slotIndex, attachmentName);
    return null;
  }
View Full Code Here

    if (slotName == null) throw new IllegalArgumentException("slotName cannot be null.");
    Array<Slot> slots = this.slots;
    for (int i = 0, n = slots.size; i < n; i++) {
      Slot slot = slots.get(i);
      if (slot.data.name.equals(slotName)) {
        Attachment attachment = null;
        if (attachmentName != null) {
          attachment = getAttachment(i, attachmentName);
          if (attachment == null)
            throw new IllegalArgumentException("Attachment not found: " + attachmentName + ", for slot: " + slotName);
        }
View Full Code Here

      for (int i = 0, n = input.readInt(true); i < n; i++) {
        Skin skin = skeletonData.skins.get(input.readInt(true));
        for (int ii = 0, nn = input.readInt(true); ii < nn; ii++) {
          int slotIndex = input.readInt(true);
          for (int iii = 0, nnn = input.readInt(true); iii < nnn; iii++) {
            Attachment attachment = skin.getAttachment(slotIndex, input.readString());
            int frameCount = input.readInt(true);
            FfdTimeline timeline = new FfdTimeline(frameCount);
            timeline.slotIndex = slotIndex;
            timeline.attachment = attachment;
            for (int frameIndex = 0; frameIndex < frameCount; frameIndex++) {
View Full Code Here

      Skin skin = new Skin(skinMap.name);
      for (JsonValue slotEntry = skinMap.child; slotEntry != null; slotEntry = slotEntry.next) {
        int slotIndex = skeletonData.findSlotIndex(slotEntry.name);
        if (slotIndex == -1) throw new SerializationException("Slot not found: " + slotEntry.name);
        for (JsonValue entry = slotEntry.child; entry != null; entry = entry.next) {
          Attachment attachment = readAttachment(skin, entry.name, entry);
          if (attachment != null) skin.addAttachment(slotIndex, entry.name, attachment);
        }
      }
      skeletonData.skins.add(skin);
      if (skin.name.equals("default")) skeletonData.defaultSkin = skin;
View Full Code Here

      for (JsonValue slotMap = ffdMap.child; slotMap != null; slotMap = slotMap.next) {
        int slotIndex = skeletonData.findSlotIndex(slotMap.name);
        if (slotIndex == -1) throw new SerializationException("Slot not found: " + slotMap.name);
        for (JsonValue meshMap = slotMap.child; meshMap != null; meshMap = meshMap.next) {
          FfdTimeline timeline = new FfdTimeline(meshMap.size);
          Attachment attachment = skin.getAttachment(slotIndex, meshMap.name);
          if (attachment == null) throw new SerializationException("FFD attachment not found: " + meshMap.name);
          timeline.slotIndex = slotIndex;
          timeline.attachment = attachment;

          int vertexCount;
View Full Code Here

    polygonPool.freeAll(polygons);
    polygons.clear();

    for (int i = 0; i < slotCount; i++) {
      Slot slot = slots.get(i);
      Attachment attachment = slot.attachment;
      if (attachment instanceof BoundingBoxAttachment) {
        BoundingBoxAttachment boundingBox = (BoundingBoxAttachment)attachment;
        boundingBoxes.add(boundingBox);

        FloatArray polygon = polygonPool.obtain();
View Full Code Here

    if (drawRegionAttachments) {
      shapes.setColor(attachmentLineColor);
      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]);
        }
      }
    }

    if (drawMeshHull || drawMeshTriangles) {
      Array<Slot> slots = skeleton.getSlots();
      for (int i = 0, n = slots.size; i < n; i++) {
        Slot slot = slots.get(i);
        Attachment attachment = slot.attachment;
        float[] vertices = null;
        short[] triangles = null;
        int hullLength = 0;
        if (attachment instanceof MeshAttachment) {
          MeshAttachment mesh = (MeshAttachment)attachment;
View Full Code Here

TOP

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

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.