Last active
October 22, 2015 11:47
-
-
Save ahmed-abdurrahman/576e6c6001f6e89565e0 to your computer and use it in GitHub Desktop.
More fun, by adding UIDynamicItemBehavior
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lazy var dynamicItemBehavior:UIDynamicItemBehavior = { | |
let lazyBehavior = UIDynamicItemBehavior() | |
// Let's make our square elastic | |
// 0 = no elacticity, 1.0 = max elacticity | |
lazyBehavior.elasticity = 0.8 | |
// Other configurations | |
// lazyBehavior.allowsRotation | |
// lazyBehavior.density | |
// lazyBehavior.friction | |
// lazyBehavior.resistance | |
return lazyBehavior | |
}() | |
func animateSquare(){ | |
animator.addBehavior(gravity) | |
animator.addBehavior(collider) | |
// Add the dynamicItemBehavior to the animator | |
animator.addBehavior(dynamicItemBehavior) | |
collider.addItem(squareView) | |
gravity.addItem(squareView) | |
// And add the squareView to the dynamicItemBehavior | |
dynamicItemBehavior.addItem(squareView) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment