File tree 4 files changed +7
-4
lines changed
4 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -53,9 +53,9 @@ extension Board {
53
53
var distanceToDropPoint = CGFloat . max
54
54
for square in squaresSurrounding ( potentialSquare) {
55
55
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
59
59
// No need to sqrt since we're just comparing
60
60
let distance = ( xDistance * xDistance) + ( yDistance * yDistance)
61
61
if distance < distanceToDropPoint {
Original file line number Diff line number Diff line change @@ -39,9 +39,11 @@ extension BoardView {
39
39
40
40
var dropPath : CGPath ? {
41
41
set {
42
+ let origin = highlightLayer. position
42
43
CATransaction . begin ( )
43
44
CATransaction . setDisableActions ( true )
44
45
highlightLayer. path = newValue
46
+ highlightLayer. position = origin
45
47
CATransaction . commit ( )
46
48
}
47
49
get {
Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ public class PentominoesViewController: UIViewController {
76
76
77
77
@IBAction func handleTap( sender: UITapGestureRecognizer ) {
78
78
activeTile? . rotate ( true )
79
+ boardView. dropPath = activeTile? . tile. pathForSquares ( true , gridSize: gridSize)
79
80
}
80
81
81
82
@IBAction func handlePan( sender: UIPanGestureRecognizer ) {
Original file line number Diff line number Diff line change @@ -30,11 +30,11 @@ public class TileView: UIView {
30
30
}
31
31
32
32
func rotate( clockwise: Bool ) {
33
+ self . tile. rotate ( clockwise)
33
34
UIView . animateWithDuration ( 0.1 , animations: {
34
35
self . transform = CGAffineTransformMakeRotation ( clockwise ? CGFloat ( M_PI_2) : CGFloat ( - M_PI_2) )
35
36
} , completion: { _ in
36
37
self . transform = CGAffineTransformIdentity
37
- self . tile. rotate ( clockwise)
38
38
self . shapeLayer. path = self . tilePath ( )
39
39
} )
40
40
}
You can’t perform that action at this time.
0 commit comments