UMD.HCIL.Piccolo.PNode.AnimateToMatrix C# (CSharp) Method

AnimateToMatrix() public method

Animate this node's matrix from its current values when the activity starts to the new values specified in the given matrix.
If this node descends from the root then the activity will be scheduled, else the returned activity should be scheduled manually. If two different transform activities are scheduled for the same node at the same time, they will both be applied to the node, but the last one scheduled will be applied last on each frame, so it will appear to have replaced the original. Generally you will not want to do that.
public AnimateToMatrix ( UMD.HCIL.Piccolo.Util.PMatrix destMatrix, long duration ) : UMD.HCIL.Piccolo.Activities.PTransformActivity
destMatrix UMD.HCIL.Piccolo.Util.PMatrix The final matrix value.
duration long The amount of time that the animation should take.
return UMD.HCIL.Piccolo.Activities.PTransformActivity
		public virtual PTransformActivity AnimateToMatrix(PMatrix destMatrix, long duration) {
			if (duration == 0) {
				Matrix = destMatrix;
				return null;
			}

			PTransformActivity.Target t = new PNodeTransformTarget(this);
			PTransformActivity ta = new PTransformActivity(duration, PUtil.DEFAULT_ACTIVITY_STEP_RATE, t, destMatrix);
			AddActivity(ta);
			return ta;
		}

Usage Example

Example #1
0
		/// <summary>
		/// Hilite the specified slide - or unhilite all slides if hiliteIndex is -1.
		/// </summary>
		private void HiliteSlide(int newHiliteIndex) {
			PNode newSlide = null;
			if (newHiliteIndex >= 0) {
				newSlide = slides[newHiliteIndex];
			}
			if (newSlide != hiliteSlide) {
				// First unhilite previously hilited slide
				if ((hiliteSlide != null) && (hiliteSlide != focusSlide)) {
					// If this slide is currently animating, then kill that animation
					int index = (int)hiliteSlide.Tag;
					if (slideActivities[index] != null) {
						slideActivities[index].Terminate();
						slideActivities[index] = null;
					}
					(hiliteSlide as PMultiSizeImage).ShowThumb = true;
					(hiliteSlide as PMultiSizeImage).Hilite = false;
					PTransformActivity activity = hiliteSlide.AnimateToMatrix(GetUnfocusedMatrix(hiliteSlide, (int)hiliteSlide.Tag), SLIDEBAR_ANIMATION_TIME_MILLIS);
					// Put the slide in order when the animation finishes
					activity.ActivityFinished = new ActivityFinishedDelegate(HiliteActivityFinished);
					hiliteSlide = null;
				}
				// Then hilite new slide (as long is it isn't the currently focused slide)
				if (newSlide != focusSlide) {
					hiliteSlide = newSlide;
					if (hiliteSlide != null) {
						PMatrix matrix = GetUnfocusedMatrix(hiliteSlide, (int)hiliteSlide.Tag);
						matrix.ScaleBy(1.3f, (hiliteSlide.Bounds.Width / 2), hiliteSlide.Bounds.Height);
						(hiliteSlide as PMultiSizeImage).Hilite = true;
						hiliteSlide.MoveToFront();
						currentPosition.MoveToFront();
						slideActivities[newHiliteIndex] = hiliteSlide.AnimateToMatrix(matrix, SLIDEBAR_ANIMATION_TIME_MILLIS);
					}
				}
			}
		}