Created
October 21, 2015 06:57
-
-
Save ahmed-abdurrahman/05b0526a7d700044b295 to your computer and use it in GitHub Desktop.
Adding UICollisionBehavior
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 collider:UICollisionBehavior = { | |
let lazyCollider = UICollisionBehavior() | |
// This line, makes the boundries of our reference view a boundary | |
// for the added items to collide with. | |
lazyCollider.translatesReferenceBoundsIntoBoundary = true | |
return lazyCollider | |
}() | |
// This is how our animate function will look like | |
func animateSquare(){ | |
animator.addBehavior(gravity) | |
// Add the collider also to the animator | |
animator.addBehavior(collider) | |
// Add the squareView to both behaviors | |
collider.addItem(squareView) | |
gravity.addItem(squareView) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment