public void AddKeyframe(Keyframe newframe) { Keyframe[] newframes = new Keyframe[keyframes.Length + 1]; for (int i = 0; i < keyframes.Length; i++) { newframes[i] = keyframes[i]; } newframes[keyframes.Length] = newframe; keyframes = newframes; }
public Keyframe Copy() { Keyframe frame = new Keyframe(); foreach (string rect in GetRectangles.Keys) { frame.GetRectangles.Add(rect, GetRectangles[rect].Copy()); } frame.KeyFrameNumber = keyframenumber; return frame; }
public Animation() { keyframes = new Keyframe[1]; keyframes[0] = new Keyframe(); }
public void RemoveKeyframe(int number) { Keyframe[] oldframes = (Keyframe[])keyframes.Clone(); Keyframe[] newframes = new Keyframe[oldframes.Length-1]; //oldframes.CopyTo(newframes, 0); for (int i = 0; i < newframes.Length; i++) { newframes[i] = oldframes[i].Copy(); } for (int i = number; i < newframes.Length; i++) { newframes[i] = oldframes[i+1].Copy(); } for (int i = 0; i < newframes.Length; i++) { newframes[i].KeyFrameNumber = i; } keyframes = newframes; }
public void LoadAnimation(string data,string[] rectangles) { string[] frames = data.Split('#'); keyframes = new Keyframe[frames.Length]; for (int i = 0; i < keyframes.Length; i++) { keyframes[i] = new Keyframe(); keyframes[i].LoadFrame(rectangles, frames[i],i); } }
private void SetKeyFrameList(Keyframe[] newframes) { KeyframeListBox.Items.Clear(); foreach (Keyframe frame in newframes) { KeyframeListBox.Items.Add(frame); } KeyframeListBox.SelectedIndex = (int)MathHelper.Clamp(enemyControl.Enemy.Animations.CurrentAnimationKeyFrameValue,0,newframes.Length-1); }
private void copyButton_Click(object sender, EventArgs e) { Keyframe originframe = (Keyframe)KeyframeListBox.SelectedItem; Keyframe copyframe = new Keyframe(); foreach (string rect in originframe.GetRectangles.Keys) { copyframe.GetRectangles.Add(rect, originframe.GetRectangles[rect].Copy()); } //copyframe.GetRectangles = originframe.GetRectangles; copyframe.KeyFrameNumber = enemyControl.Enemy.Animations.CurrentAnimationKeyFrameCount; enemyControl.Enemy.Animations.Animations[(int)enemyControl.Enemy.Animations.CurrentAnimation].AddKeyframe(copyframe); SetKeyFrameList(enemyControl.Enemy.Animations.CurrentAnimationKeyframes); }