我一直在尝试通过“Make Games With Us”来了解如何制作 John Conway 的“生命游戏”。在我达到 MainScene.m 的 step 方法之前,我能够遵循大部分教程(这里是该站点的链接):
- (void)step
{
[_grid evolveStep]
_generationLabel.string = [NSString stringWithFormat:@"%d", _grid.generation];
_populationLabel.string = [NSString stringWithFormat:@"%d", _grid.totalAlive];
}
错误属于同一类型;他们出现在 _grid.generation 和 _grid.totalAlive。错误如下:
Property 'generation' not found on object of type 'Grid *'
Property 'totalAlive' not found on object of type 'Grid *'
我已经查看了有关如何解决相同问题的链接,但我在 SpriteBuilder 中正确保存并发布了所有内容;用户显然解决了它,但我不知道如何解决。
更新:缺少属性声明(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
先感谢您!