public void MoveRandom() { if (animator != null) { return; } float duration = 1; duration = durations[randomizer.Next(0, durations.Length)]; OOEInterpolation interpolation = interpolations[randomizer.Next(0, interpolations.Length)]; animator = new OOEValueAnimator().Duration(duration).From(0).To(1).Interpolation(interpolation); previousLocation = frame.origin; destination.x = ((float)randomizer.NextDouble() * playgroundSize.width) - frame.origin.x; destination.y = ((float)randomizer.NextDouble() * playgroundSize.height) - frame.origin.y; animator.OnValueChange = (value) => { frame.origin.x = previousLocation.x + (destination.x * value); frame.origin.y = previousLocation.y + (destination.y * value); }; animator.OnFinish = () => { animator.Dispose(); animator = null; MoveRandom(); }; animator.Start(); }
public override void Dispose() { if (animator != null) { animator.Stop(); animator.Dispose(); } }
public override void Dispose() { if (playerOrbAnimator != null) { playerOrbAnimator.Stop(); playerOrbAnimator.Dispose(); playerOrbAnimator = null; } }
private void MakeBackwardAnimator() { bgAnimator = new OOEValueAnimator().Duration(3).To(0x51ff94).From(0xffd941).Interpolation(OOEInterpolation.easeInOut); bgAnimator.OnValueChange = (value) => { var color = (int)value; this.gradientView.BackColor = Color.FromArgb(0xff, (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff); }; bgAnimator.Start(); bgAnimator.OnFinish = () => { bgAnimator.Dispose(); MakeForwardAnimator(); }; }
public void StartAnimation() { if (animation == null) { animation = new OOEValueAnimator().Duration(1.0f).From(0).To(30).Interpolation(OOEInterpolation.easeOut); animation.OnValueChange = (value) => { frame.origin.y = point.y - value; }; animation.OnFinish = () => { if (completion != null) { completion(); } animation.Stop(); animation.Dispose(); animation = null; }; animation.Start(); } }
public void MoveTo(CGPoint point) { if (CanMove == false) { return; } CanMove = false; playerStartX = this.frame.origin.x; playerStartY = this.frame.origin.y; float x = point.x; float y = point.y; x -= this.frame.size.width / 2; y -= this.frame.size.height / 2; playerTotalX = x - playerStartX; playerTotalY = y - playerStartY; float duration = targetDuration; // float rd_2 = 1; float d_2 = 1; if (RelativeDiagonalTimeLine != 0) { // rd_2 = (float)Math.Sqrt(Math.Pow(RelativeDiagonalTimeLine, 2)); d_2 = (float)Math.Sqrt((Math.Pow(playerTotalX, 2) + Math.Pow(playerTotalY, 2))); duration = targetDuration * (d_2 / RelativeDiagonalTimeLine); if (duration > targetDuration) { duration = targetDuration; } } /* * MessageBox.Show("Relative : " + RelativeDiagonalTimeLine + * "\nrd_2 : " + rd_2 + * "\nd_2 : " + d_2 + * "\npercent : " + d_2 / rd_2 + * "\nduration:" + duration); */ playerOrbAnimator = new OOEValueAnimator().From(0).To(1.0f).Duration(duration).Interpolation(OOEInterpolation.linear); playerOrbAnimator.OnValueChange = (value) => { int cx = (int)(((float)playerTotalX * value) + playerStartX); int cy = (int)(((float)playerTotalY * value) + playerStartY); // playerOrb.Location = new Point(cx, cy); this.frame.origin.x = cx; this.frame.origin.y = cy; // playerOrb.Update(); // this.Invalidate(); }; playerOrbAnimator.OnFinish = () => { CanMove = true; playerOrbAnimator.Dispose(); playerOrbAnimator = null; }; playerOrbAnimator.Start(); }