I was just following Ray Wenderlich’s tutorial here:
I’m using C*+ on Windows to make a “Farmville” type game so I have to somehow convert all of his code to C*+. I’m using Cocos2dx v2.0-2.04. The part where I am stuck is
CCTMXObjectGroup *objects = [_tileMap objectGroupNamed:@"Objects"]; NSAssert(objects != nil, @"'Objects' object group not found"); NSMutableDictionary *spawnPoint = [objects objectNamed:@"SpawnPoint"]; NSAssert(spawnPoint != nil, @"SpawnPoint object not found"); int x = [[spawnPoint valueForKey:@"x"] intValue]; int y = [[spawnPoint valueForKey:@"y"] intValue];
and my converted code is
CCTMXObjectGroup* objects = tileMap->objectGroupNamed("Objects"); CC_BREAK_IF(! objects); CCDictionary* spawnPoint = objects->objectNamed("SpawnPoint"); CC_BREAK_IF(! spawnpoint); int x = spawnPoint->valueForKey("x"); int y = spawnPoint->valueForKey("y");
The part with valueForKey for x and y shows the error of:
Error: a value of type “const cocos2d::CCString *” cannot be used to initialize an entity of type “int”
Could someone tell me what went wrong?