Check out the new forum. You are currently viewing the old forum. It will be saved and searchable for future reference.

HomeForumGeneral DiscussionGetting level properties

Author Posts
Author Posts
August 20, 2010 at 9:31 pm #183

CyberGreg

So I have added some properties to the objs level in my TMX file, with information about the level. My ultimate goal is to provide a “Welcome to <name>” notice. Where <name> is pulled from the name property of the level.

I can NSLog the information so I’m pretty sure I’m headed in the right direction, just now I’m not sure how to get at this info.

This code is in the for loop in the createObjects method

if([objs propertyNamed:@"name"]) {
			NSLog(@"name:%@",[objs propertyNamed:@"name"]);
		}

and it correctly lists the info I have entered for name but how would I get this from/to the HUD to display it? Should I be sending this to some other area like the GameState?

August 20, 2010 at 10:12 pm #690

stahlmanDesign

It would also be cool to be add different properties to the same type of object in Tiled, so that different enemies, while being the same type, could each have individual messages/uniqueness.

One might say “welcome he he he…” if placed to guard the entrance of a dungeon, and the same object type could carry the message “you’ll never get the gold” if he is guarding the treasure near the end.

August 23, 2010 at 6:16 pm #695

Nathanael Weiss

@CyberGreg: It kind of depends on how you are setting up your HUD to display the messages. It would make sense to store the data you get in the createObjects message inside a LevelObject derived object. Then when you “talk” to that object it could use it’s getHud method to call a “message box” type of method.