I have been attempting to follow on how to make John Conway's 'Game of Life' through 'Make Games With Us'. I was able to follow for most of the tutorial until I reached in the step method of MainScene.m (here is the link to the site):
- (void)step
{
[_grid evolveStep]
_generationLabel.string = [NSString stringWithFormat:@"%d", _grid.generation];
_populationLabel.string = [NSString stringWithFormat:@"%d", _grid.totalAlive];
}
The errors are of the same type; they're showing up at _grid.generation and _grid.totalAlive. The error is the following:
Property 'generation' not found on object of type 'Grid *'
Property 'totalAlive' not found on object of type 'Grid *'
I have looked at this link on how to fix the very same issue, yet I saved and published everything correctly in SpriteBuilder; the user apparently solved it, but I cannot find out how.
Update: Missing Property Declaration (Grid.m):
#import "Grid.h"
#import "Creature.h"
// variables that cannot be changed
static const int GRID_ROWS = 8;
static const int GRID_COLUMNS = 10;
@implementation Grid {
NSMutableArray *_gridArray;
float _cellWidth;
float _cellHeight;
int _generation; // This one
int _totalAlive; // This one
}
/*Rest of the methods go here*/
@end
Thank you in advance!
This unfortunately was a mistake in our tutorial.
Indeed you need to add two properties to Grid.h
:
@property (nonatomic, assign) int totalAlive;
@property (nonatomic, assign) int generation;
Instead of adding instance variables to Grid.m
.
The tutorial has now been updated: https://www.makegameswith.us/tutorials/game-of-life-spritebuilder/game-of-life-code/
You can also find the entire code for the solution on GitHub: https://github.com/MakeGamesWithUs/GameOfLife.spritebuilder
Sorry for the inconvenience!