Skip to content

Commit 44f9e6b

Browse files
committed
bug fixes
1 parent 3571d6b commit 44f9e6b

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

Pentominoes/Board.swift

+3-3
Original file line numberDiff line numberDiff 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 {

Pentominoes/BoardView.swift

+2
Original file line numberDiff line numberDiff 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 {

Pentominoes/PentominoesViewController.swift

+1
Original file line numberDiff line numberDiff 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) {

Pentominoes/TileView.swift

+1-1
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)