diff --git a/m2048/Sprite Kit/M2Tile.m b/m2048/Sprite Kit/M2Tile.m
index b2040a2e..0f6a000a 100644
--- a/m2048/Sprite Kit/M2Tile.m
+++ b/m2048/Sprite Kit/M2Tile.m
@@ -130,7 +130,8 @@ - (NSInteger)mergeToTile:(M2Tile *)tile
// 3. Update value and pop.
[self updateLevelTo:newLevel];
- [_pendingActions addObject:[self pop]];
+
+ [self runAction:[self pop]];
}
return newLevel;
}
@@ -153,7 +154,8 @@ - (NSInteger)merge3ToTile:(M2Tile *)tile andTile:(M2Tile *)furtherTile
// 3. Update value and pop.
[self updateLevelTo:newLevel];
- [_pendingActions addObject:[self pop]];
+
+ [self runAction:[self pop]];
}
return newLevel;
}
@@ -181,11 +183,13 @@ - (void)refreshValue
- (void)moveToCell:(M2Cell *)cell
{
- [_pendingActions addObject:[SKAction moveBy:[GSTATE distanceFromPosition:self.cell.position
- toPosition:cell.position]
- duration:GSTATE.animationDuration]];
+ SKAction * move = [SKAction moveBy:[GSTATE distanceFromPosition:self.cell.position
+ toPosition:cell.position]
+ duration:GSTATE.animationDuration];
self.cell.tile = nil;
cell.tile = self;
+
+ [self runAction:move];
}
diff --git a/m2048/State/M2GameManager.m b/m2048/State/M2GameManager.m
index 32f79fe1..18351b36 100644
--- a/m2048/State/M2GameManager.m
+++ b/m2048/State/M2GameManager.m
@@ -25,7 +25,6 @@ BOOL iterate(NSInteger value, BOOL countUp, NSInteger upper, NSInteger lower) {
return countUp ? value < upper : value > lower;
}
-
@implementation M2GameManager {
/** True if game over. */
BOOL _over;
@@ -46,7 +45,7 @@ @implementation M2GameManager {
M2Grid *_grid;
/** The display link to add tiles after removing all existing tiles. */
- CADisplayLink *_addTileDisplayLink;
+// CADisplayLink *_addTileDisplayLink;
}
@@ -54,39 +53,49 @@ @implementation M2GameManager {
- (void)startNewSessionWithScene:(M2Scene *)scene
{
- if (_grid && _grid.dimension == GSTATE.dimension) {
- // If there is an existing grid and its dimension is still valid,
- // we keep it, only removing all existing tiles with animation.
- [_grid removeAllTilesAnimated:YES];
- } else {
- if (_grid) [_grid removeAllTilesAnimated:NO];
- _grid = [[M2Grid alloc] initWithDimension:GSTATE.dimension];
- _grid.scene = scene;
- }
+// if (_grid && _grid.dimension == GSTATE.dimension) {
+// // If there is an existing grid and its dimension is still valid,
+// // we keep it, only removing all existing tiles with animation.
+// [_grid removeAllTilesAnimated:YES];
+// } else {
+// if (_grid) [_grid removeAllTilesAnimated:NO];
+// _grid = [[M2Grid alloc] initWithDimension:GSTATE.dimension];
+// _grid.scene = scene;
+// }
+
+ // Restart bug still occure, this seems to fix the PB
+ if (_grid)
+ [_grid removeAllTilesAnimated:NO];
+ _grid = [[M2Grid alloc] initWithDimension:GSTATE.dimension];
+ _grid.scene = scene;
+
[scene loadBoardWithGrid:_grid];
// Set the initial state for the game.
_score = 0; _over = NO; _won = NO; _keepPlaying = NO;
+ // Bug on restart if the scene is full, this seens to fix it
+ [_grid insertTileAtRandomAvailablePositionWithDelay:NO];
+ [_grid insertTileAtRandomAvailablePositionWithDelay:NO];
+
// Existing tile removal is async and happens in the next screen refresh, so we'd wait a bit.
- _addTileDisplayLink = [CADisplayLink displayLinkWithTarget:self
- selector:@selector(addTwoRandomTiles)];
- [_addTileDisplayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
+// _addTileDisplayLink = [CADisplayLink displayLinkWithTarget:self
+// selector:@selector(addTwoRandomTiles)];
+// [_addTileDisplayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
}
-- (void)addTwoRandomTiles
-{
- // If the scene only has one child (the board), we can proceed with adding new tiles
- // since all old ones are removed. After adding new tiles, remove the displaylink.
- if (_grid.scene.children.count <= 1) {
- [_grid insertTileAtRandomAvailablePositionWithDelay:NO];
- [_grid insertTileAtRandomAvailablePositionWithDelay:NO];
- [_addTileDisplayLink invalidate];
- }
-}
-
+//- (void)addTwoRandomTiles
+//{
+// // If the scene only has one child (the board), we can proceed with adding new tiles
+// // since all old ones are removed. After adding new tiles, remove the displaylink.
+// if (_grid.scene.children.count <= 1) {
+// [_grid insertTileAtRandomAvailablePositionWithDelay:NO];
+// [_grid insertTileAtRandomAvailablePositionWithDelay:NO];
+// [_addTileDisplayLink invalidate];
+// }
+//}
# pragma mark - Actions
diff --git a/m2048/m2048-Info.plist b/m2048/m2048-Info.plist
index 4a4b35da..ad77d993 100644
--- a/m2048/m2048-Info.plist
+++ b/m2048/m2048-Info.plist
@@ -9,7 +9,7 @@
CFBundleExecutable
${EXECUTABLE_NAME}
CFBundleIdentifier
- me.danqing.${PRODUCT_NAME:rfc1034identifier}
+ me.danqing.$(PRODUCT_NAME:rfc1034identifier)
CFBundleInfoDictionaryVersion
6.0
CFBundleName
@@ -17,11 +17,11 @@
CFBundlePackageType
APPL
CFBundleShortVersionString
- 1.1
+ 1.2
CFBundleSignature
????
CFBundleVersion
- 4
+ 5
LSApplicationCategoryType
LSRequiresIPhoneOS