views:

215

answers:

3

i have this code and on the second line it gives me an error that says invalid initialzer this is the code:

-(void)setPlayerPosition:(CGPoint)position {
 CGPoint tileCoord = [self tileCoordForPosition:position];
 int tileGid = [_meta tileGIDAt:tileCoord];
 if (tileGid) {
  NSDictionary *properties = [_tileMap propertiesForGID:tileGid];
  if (properties) {
   NSString *collision = [properties valueForKey:@"Collidable"];
   if (collision && [collision compare:@"True"] == NSOrderedSame) {
    return;
   }
  }
 }
 _player.position = position;
}
A: 

I really cant tell you anything without an error from the compiler or stack trace, also it would be better to post what type of objects _meta and _tileMap and _player are. As i say to many clients please provide more information and we can provide the answer.

kohlerfc
A: 

I'm going to use my psychic powers and guess that you accidentally declared tileCoordForPosition: as returning a CGPoint* (that is, a pointer to a CGPoint) rather than a CGPoint.

(It would, however, have been helpful if you'd shown the relevant code so I wouldn't have to fire up the ESP.)

Chuck
A: 

I have the same problem with you. But when I declare function [tileCoordForPosition] in .h file, everything is built success.

Chanyut