Permalink
Browse files

bug fixes

  • Loading branch information...
jrturton committed Aug 14, 2016
1 parent 3571d6b commit 44f9e6b55ff3cd4716888c898d7127a448115049
View
@@ -53,9 +53,9 @@ extension Board {
var distanceToDropPoint = CGFloat.max
for square in squaresSurrounding(potentialSquare) {
if canPositionTile(tile, atSquare: square) {
- let center = pointAtCenterOfSquare(square, gridSize: gridSize)
- let xDistance = center.x - point.x
- let yDistance = center.y - point.y
+ let origin = pointAtOriginOfSquare(square, gridSize: gridSize)
+ let xDistance = origin.x - point.x
+ let yDistance = origin.y - point.y
// No need to sqrt since we're just comparing
let distance = (xDistance * xDistance) + (yDistance * yDistance)
if distance < distanceToDropPoint {
@@ -39,9 +39,11 @@ extension BoardView {
var dropPath: CGPath? {
set {
+ let origin = highlightLayer.position
CATransaction.begin()
CATransaction.setDisableActions(true)
highlightLayer.path = newValue
+ highlightLayer.position = origin
CATransaction.commit()
}
get {
@@ -76,6 +76,7 @@ public class PentominoesViewController: UIViewController {
@IBAction func handleTap(sender: UITapGestureRecognizer) {
activeTile?.rotate(true)
+ boardView.dropPath = activeTile?.tile.pathForSquares(true, gridSize: gridSize)
}
@IBAction func handlePan(sender: UIPanGestureRecognizer) {
@@ -30,11 +30,11 @@ public class TileView: UIView {
}
func rotate(clockwise: Bool) {
+ self.tile.rotate(clockwise)
UIView.animateWithDuration(0.1, animations: {
self.transform = CGAffineTransformMakeRotation(clockwise ? CGFloat(M_PI_2) : CGFloat(-M_PI_2))
}, completion: { _ in
self.transform = CGAffineTransformIdentity
- self.tile.rotate(clockwise)
self.shapeLayer.path = self.tilePath()
})
}

0 comments on commit 44f9e6b

Please sign in to comment.