File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -53,9 +53,9 @@ extension Board {
5353 var distanceToDropPoint = CGFloat . max
5454 for square in squaresSurrounding ( potentialSquare) {
5555 if canPositionTile ( tile, atSquare: square) {
56- let center = pointAtCenterOfSquare ( square, gridSize: gridSize)
57- let xDistance = center . x - point. x
58- let yDistance = center . y - point. y
56+ let origin = pointAtOriginOfSquare ( square, gridSize: gridSize)
57+ let xDistance = origin . x - point. x
58+ let yDistance = origin . y - point. y
5959 // No need to sqrt since we're just comparing
6060 let distance = ( xDistance * xDistance) + ( yDistance * yDistance)
6161 if distance < distanceToDropPoint {
Original file line number Diff line number Diff line change @@ -39,9 +39,11 @@ extension BoardView {
3939
4040 var dropPath : CGPath ? {
4141 set {
42+ let origin = highlightLayer. position
4243 CATransaction . begin ( )
4344 CATransaction . setDisableActions ( true )
4445 highlightLayer. path = newValue
46+ highlightLayer. position = origin
4547 CATransaction . commit ( )
4648 }
4749 get {
Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ public class PentominoesViewController: UIViewController {
7676
7777 @IBAction func handleTap( sender: UITapGestureRecognizer ) {
7878 activeTile? . rotate ( true )
79+ boardView. dropPath = activeTile? . tile. pathForSquares ( true , gridSize: gridSize)
7980 }
8081
8182 @IBAction func handlePan( sender: UIPanGestureRecognizer ) {
Original file line number Diff line number Diff line change @@ -30,11 +30,11 @@ public class TileView: UIView {
3030 }
3131
3232 func rotate( clockwise: Bool ) {
33+ self . tile. rotate ( clockwise)
3334 UIView . animateWithDuration ( 0.1 , animations: {
3435 self . transform = CGAffineTransformMakeRotation ( clockwise ? CGFloat ( M_PI_2) : CGFloat ( - M_PI_2) )
3536 } , completion: { _ in
3637 self . transform = CGAffineTransformIdentity
37- self . tile. rotate ( clockwise)
3838 self . shapeLayer. path = self . tilePath ( )
3939 } )
4040 }
You can’t perform that action at this time.
0 commit comments