Reputation: 147
I'm working with tile map using Tiled. I have an object on my map for the player spawn point.
I have been able to spawn the player object. However, I'm at a loss as to how to access the player objects functions or IVARs??
In MyScene:
TileMapLayer *_playerLayer = [[TmxTileMapLayer alloc]
initWithTmxObjectGroup:[_tileMap groupNamed:@"Spawn"]
tileSize:_tileMap.tileSize
gridSize:_bgLayer.gridSize
objectType:@"Player"];
[_worldNode addChild:_playerLayer];
This will create a player object. The player object has functions that I want to run and IVARs I want to query. Note, some of the functions return values.
Example from the Player object:
- (BOOL)currentWeaponStatus
{
return _weapon.hidden;
}
So far I think I can access it using:
BOOL weaponHidden = [[_playerLayer childNodeWithName:@"person"] childNodeWithName:@"weapon"].hidden;
But this doesn't seem 'simple'. How do I access the child nodes' functions/IVARs in the _playerLayer?
FYI: I have a weapon node on the player node - this gets added to the tile map layer node.
Thanks for your time. -Shoes
Upvotes: 0
Views: 118
Reputation: 147
This is what I needed:
Person *player = (Person *)[_playerLayer childNodeWithName:@"person"];
Thanks to the Chris at Ray Wenderlich...
http://www.raywenderlich.com/forums/viewtopic.php?f=38&t=11775&p=61090#p61090
Upvotes: 1