Beispiel #1
0
        /// <summary>
        /// Maps all object from the parent's coordinate system to the global coordinate system. </summary>
        /// <param name="base"> the root bone to start at. Set it to <code>null</code> to traverse the whole bone hierarchy. </param>
        public virtual void UnmapObjects(Mainline.Key.BoneRef @base)
        {
            int start = @base == null ? -1 : @base.Id - 1;

            for (int i = start + 1; i < CurrentKey.BoneRefs.Length; i++)
            {
                Mainline.Key.BoneRef @ref = CurrentKey.GetBoneRef(i);
                if (@ref.Parent != @base && @base != null)
                {
                    continue;
                }
                Bone parent = @ref.Parent == null ? this.Root : this.UnmappedTweenedKeys[@ref.Parent.Timeline].Object;
                UnmappedTweenedKeys[@ref.Timeline].Object.Set(TweenedKeys[@ref.Timeline].Object);
                UnmappedTweenedKeys[@ref.Timeline].Object.Unmap(parent);
                UnmapObjects(@ref);
            }
            foreach (Mainline.Key.ObjectRef @ref in CurrentKey.ObjectRefs)
            {
                if (@ref.Parent != @base && @base != null)
                {
                    continue;
                }
                Bone parent = @ref.Parent == null ? this.Root : this.UnmappedTweenedKeys[@ref.Parent.Timeline].Object;
                UnmappedTweenedKeys[@ref.Timeline].Object.Set(TweenedKeys[@ref.Timeline].Object);
                UnmappedTweenedKeys[@ref.Timeline].Object.Unmap(parent);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Sets the given values of the bone with the given name. </summary>
        /// <param name="name"> the name of the bone </param>
        /// <param name="x"> the new x value of the bone </param>
        /// <param name="y"> the new y value of the bone </param>
        /// <param name="angle"> the new angle of the bone </param>
        /// <param name="scaleX"> the new scale in x direction of the bone </param>
        /// <param name="scaleY"> the new scale in y direction of the bone </param>
        /// <exception cref="SpriterException"> if no bone exists of the given name </exception>
        public virtual void SetBone(string name, float x, float y, float angle, float scaleX, float scaleY)
        {
            int index = GetBoneIndex(name);

            if (index == -1)
            {
                throw new SpriterException("No bone found of name \"" + name + "\"");
            }
            Mainline.Key.BoneRef @ref = CurrentKey.GetBoneRef(index);
            Bone bone = GetBone(index);

            bone.Set(x, y, angle, scaleX, scaleY, 0f, 0f);
            UnmapObjects(@ref);
        }
Beispiel #3
0
 /// <summary>
 /// Returns a time line bone at the given index. </summary>
 /// <param name="index"> the index of the bone </param>
 /// <returns> the bone with the given index. </returns>
 public virtual Bone GetBone(int index)
 {
     return(this.UnmappedTweenedKeys[CurrentKey.GetBoneRef(index).Timeline].Object);
 }