Skip to content

Commit 4ede9a5

Browse files
committed
Trying add the animation, not working good
1 parent 2af8df1 commit 4ede9a5

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

SnakeGame/GameFieldView.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ class GameFieldView: UIView {
3030
segmentViews.append(segmentView)
3131

3232
}else{
33-
segmentViews[index].segment = segment
33+
34+
if segmentViews[index].segment.rect != segment.rect {
35+
segmentViews[index].segment = segment
36+
}
3437
}
3538
}
3639
}
@@ -61,11 +64,8 @@ class SegmentView: UIView {
6164

6265
var segment: GameSegment!{
6366
didSet{
64-
frame = segment.rect
6567

66-
// UIView.animateWithDuration(0.10, animations: {
67-
// self.frame = self.segment.rect
68-
// })
68+
frame = segment.rect
6969

7070
setNeedsDisplay()
7171
}

SnakeGame/GameModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class GameBrain {
186186
moveHead()
187187

188188
if food.rect.contains(headPoint) {
189-
189+
190190
score = score + 1
191191

192192
delegate?.updateScoreWithScore(score)

0 commit comments

Comments
 (0)