@SuppressWarnings("null")
  public void draw(PolygonSpriteBatch batch, Skeleton skeleton) {
    boolean premultipliedAlpha = this.premultipliedAlpha;
    BlendMode blendMode = null;

    float[] vertices = null;
    short[] triangles = null;
    Array<Slot> drawOrder = skeleton.drawOrder;
    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;
        vertices = region.updateWorldVertices(slot, premultipliedAlpha);
        triangles = quadTriangles;
        texture = region.getRegion().getTexture();

      } else if (attachment instanceof MeshAttachment) {
        MeshAttachment mesh = (MeshAttachment) attachment;
        vertices = mesh.updateWorldVertices(slot, premultipliedAlpha);
        triangles = mesh.getTriangles();
        texture = mesh.getRegion().getTexture();

      } else if (attachment instanceof SkeletonAttachment) {
        Skeleton attachmentSkeleton = ((SkeletonAttachment) attachment).getSkeleton();
        if (attachmentSkeleton == null) continue;
        Bone bone = slot.getBone();
        Bone rootBone = attachmentSkeleton.getRootBone();
        float oldScaleX = rootBone.getScaleX();
        float oldScaleY = rootBone.getScaleY();
        float oldRotation = rootBone.getRotation();
        attachmentSkeleton.setPosition(bone.getWorldX(), bone.getWorldY());
        // rootBone.setScaleX(1 + bone.getWorldScaleX() - oldScaleX);
        // rootBone.setScaleY(1 + bone.getWorldScaleY() - oldScaleY);
        // Set shear.
        rootBone.setRotation(oldRotation + bone.getWorldRotationX());
        attachmentSkeleton.updateWorldTransform();

        draw(batch, attachmentSkeleton);

        attachmentSkeleton.setPosition(0, 0);
        rootBone.setScaleX(oldScaleX);
        rootBone.setScaleY(oldScaleY);
        rootBone.setRotation(oldRotation);
      }

      if (texture != null) {
        BlendMode slotBlendMode = slot.data.getBlendMode();
        if (slotBlendMode != blendMode) {
          blendMode = slotBlendMode;
          batch.setBlendFunction(blendMode.getSource(premultipliedAlpha), blendMode.getDest());
        }
        batch.draw(texture, vertices, 0, vertices.length, triangles, 0, triangles.length);
      }
    }
  }
示例#2
0
  @Override
  public void act(float delta) {
    super.act(delta);

    skeleton.setX(getX());
    skeleton.setY(getY());
    skeleton.getRootBone().setScaleX(getScaleX());
    skeleton.getRootBone().setScaleY(getScaleY());
    animationState.update(delta);
    animationState.apply(skeleton);
    skeleton.updateWorldTransform();
  }
  public Facebuttons(Everybodyloveskimchi g, String n) {
    this.game = g;
    this.assignedname = n;
    texture = new Texture(Gdx.files.internal("faceicons/" + n + ".png"));
    this.renderer = new SkeletonRenderer();
    renderer.setPremultipliedAlpha(true);
    this.atlas = new TextureAtlas(Gdx.files.internal("foodx.atlas"));
    SkeletonJson json = new SkeletonJson((TextureAtlas) atlas);
    json.setScale(0.7f);
    SkeletonData skeletonData = json.readSkeletonData(Gdx.files.internal("foodx.json"));
    skeleton = new Skeleton(skeletonData);
    skeleton.setPosition(0, 0);
    skeleton.getRootBone().setScale(0.6f);
    AnimationStateData stateData = new AnimationStateData(skeletonData);
    state = new AnimationState(stateData);
    state.setTimeScale(0.5f);
    state.setAnimation(0, "idle", false);

    setAg();

    this.setBounds(0, 0, 98f, 106f);

    this.addListener(
        new InputListener() {
          @Override
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            if (enabled) {
              System.out.println(assignedname + "down");
              clickedY = -5f;
              game.members.get(assignedname).foodtoeat = game.currentFood;
              game.sendMemeber(assignedname);
              //          clickedY
              //            moveTo(0f,100f,10);
              //
            }
            return true;
          }

          @Override
          public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            if (enabled) {
              System.out.println(assignedname + "up");
              clickedY = 0f;
              //            trip();
            }
          }
        });
  }