Skip to content

Instantly share code, notes, and snippets.

@dvdsgl
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dvdsgl/034071f4eb8990e03750 to your computer and use it in GitHub Desktop.
Save dvdsgl/034071f4eb8990e03750 to your computer and use it in GitHub Desktop.
type ShootOutAnimator(referenceView: UIView) =
let speed = 1300.0f
let animator = UIDynamicAnimator(referenceView)
...
member this.ShootOut(view: UIView, direction: Direction) =
let x, y = direction.UnitVector
let shoot = UIDynamicItemBehavior(view, AngularResistance=2.0f)
shoot.AddLinearVelocityForItem(PointF(x * speed, y * speed), view)
shoot.AddAngularVelocityForItem(x * 3.0f, view)
shoot.Action <- fun () ->
if not (referenceView.Bounds.IntersectsWith(view.Frame)) then
animator.RemoveAllBehaviors()
view.RemoveFromSuperview()
shotOut.Trigger(view)
animator.AddBehavior(shoot)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment