@Override
 protected void update(BoneRef ref, Bone root, int time) {
   boolean isObject = ref instanceof ObjectRef;
   // Tween bone/object
   Bone bone1 = null, bone2 = null, tweenTarget = null;
   Timeline t1 =
       onFirstMainLine()
           ? anim1.getTimeline(ref.timeline)
           : anim1.getSimilarTimeline(anim2.getTimeline(ref.timeline));
   Timeline t2 =
       onFirstMainLine() ? anim2.getSimilarTimeline(t1) : anim2.getTimeline(ref.timeline);
   Timeline targetTimeline = super.getTimeline(onFirstMainLine() ? t1.id : t2.id);
   if (t1 != null) bone1 = anim1.tweenedKeys[t1.id].object();
   if (t2 != null) bone2 = anim2.tweenedKeys[t2.id].object();
   if (targetTimeline != null) tweenTarget = this.tweenedKeys[targetTimeline.id].object();
   if (isObject && (t2 == null || !tweenSprites)) {
     if (!onFirstMainLine()) bone1 = bone2;
     else bone2 = bone1;
   }
   if (bone2 != null && tweenTarget != null && bone1 != null) {
     if (isObject)
       this.tweenObject(
           (Object) bone1, (Object) bone2, (Object) tweenTarget, this.weight, this.curve);
     else this.tweenBone(bone1, bone2, tweenTarget, this.weight, this.curve);
     this.unmappedTweenedKeys[targetTimeline.id].active = true;
   }
   // Transform the bone relative to the parent bone or the root
   if (this.unmappedTweenedKeys[ref.timeline].active) {
     this.unmapTimelineObject(
         targetTimeline.id,
         isObject,
         (ref.parent != null) ? this.unmappedTweenedKeys[ref.parent.timeline].object() : root);
   }
 }
 private void setUpTimelines() {
   Animation maxAnim = this.entity.getAnimationWithMostTimelines();
   int max = maxAnim.timelines();
   for (int i = 0; i < max; i++) {
     Timeline t = new Timeline(i, maxAnim.getTimeline(i).name, maxAnim.getTimeline(i).objectInfo);
     addTimeline(t);
   }
   prepare();
 }
예제 #3
0
 private void calcBoundingRectangle(BoneRef root) {
   for (BoneRef ref : getCurrentKey().boneRefs) {
     if (ref.parent != root && root != null) continue;
     Bone bone = this.unmappedTweenedKeys[ref.timeline].object();
     this.prevBBox.calcFor(bone, animation.getTimeline(ref.timeline).objectInfo);
     Rectangle.setBiggerRectangle(rect, this.prevBBox.getBoundingRect(), rect);
     this.calcBoundingRectangle(ref);
   }
   for (ObjectRef ref : getCurrentKey().objectRefs) {
     if (ref.parent != root) continue;
     Bone bone = this.unmappedTweenedKeys[ref.timeline].object();
     this.prevBBox.calcFor(bone, animation.getTimeline(ref.timeline).objectInfo);
     Rectangle.setBiggerRectangle(rect, this.prevBBox.getBoundingRect(), rect);
   }
 }
  @Override
  public void update(int time, Bone root) {
    super.currentKey = onFirstMainLine() ? anim1.currentKey : anim2.currentKey;
    for (Timeline.Key timelineKey : this.unmappedTweenedKeys) timelineKey.active = false;
    if (base != null) { // TODO: Sprites not working properly because of different timeline naming
      Animation currentAnim = onFirstMainLine() ? anim1 : anim2;
      Animation baseAnim =
          baseAnimation == null ? (onFirstMainLine() ? anim1 : anim2) : baseAnimation;
      for (BoneRef ref : currentKey.boneRefs) {
        Timeline timeline = baseAnim.getSimilarTimeline(currentAnim.getTimeline(ref.timeline));
        if (timeline == null) continue;
        Timeline.Key key, mappedKey;
        key = baseAnim.tweenedKeys[timeline.id];
        mappedKey = baseAnim.unmappedTweenedKeys[timeline.id];
        this.tweenedKeys[ref.timeline].active = key.active;
        this.tweenedKeys[ref.timeline].object().set(key.object());
        this.unmappedTweenedKeys[ref.timeline].active = mappedKey.active;
        this.unmapTimelineObject(
            ref.timeline,
            false,
            (ref.parent != null) ? this.unmappedTweenedKeys[ref.parent.timeline].object() : root);
      }
      /*for(ObjectRef ref: baseAnim.currentKey.objectRefs){
          	Timeline timeline = baseAnim.getTimeline(ref.timeline);//getSimilarTimeline(ref, tempTimelines);
          	if(timeline != null){
          		//tempTimelines.addLast(timeline);
          		Timeline.Key key = baseAnim.tweenedKeys[timeline.id];
          		Timeline.Key mappedKey = baseAnim.mappedTweenedKeys[timeline.id];
          		Object obj = (Object) key.object();

       		this.tweenedKeys[ref.timeline].active = key.active;
       		((Object)this.tweenedKeys[ref.timeline].object()).set(obj);
       		this.mappedTweenedKeys[ref.timeline].active = mappedKey.active;
      this.unmapTimelineObject(ref.timeline, true,(ref.parent != null) ?
      		this.mappedTweenedKeys[ref.parent.timeline].object(): root);
          	}
      	}*/
      // tempTimelines.clear();
    }

    this.tweenBoneRefs(base, root);
    for (ObjectRef ref : super.currentKey.objectRefs) {
      // if(ref.parent == base)
      this.update(ref, root, 0);
    }
  }
예제 #5
0
 /**
  * Returns a time line object with the given name.
  *
  * @param name the name of the object
  * @return the object with the given name
  * @throws ArrayIndexOutOfBoundsException if no object exists with the given name
  * @throws NullPointerException if no object exists with the given name
  */
 public Object getObject(String name) {
   return (Object) this.unmappedTweenedKeys[animation.getTimeline(name).id].object();
 }
예제 #6
0
 /**
  * Returns the index of a time line object with the given name.
  *
  * @param name the name of the object
  * @return the index of the object or -1 if no object exists with the given name
  */
 public int getObjectIndex(String name) {
   for (ObjectRef ref : getCurrentKey().objectRefs)
     if (animation.getTimeline(ref.timeline).name.equals(name)) return ref.id;
   return -1;
 }
예제 #7
0
 /**
  * Returns a time line bone with the given name.
  *
  * @param name the name of the bone
  * @return the bone with the given name
  * @throws ArrayIndexOutOfBoundsException if no bone exists with the given name
  * @throws NullPointerException if no bone exists with the given name
  */
 public Bone getBone(String name) {
   return this.unmappedTweenedKeys[animation.getTimeline(name).id].object();
 }