Hi guys, i’m supposed to create like a 6 min level of my game, i have to add several objects i was wondering if there is a robust way to do that instead of adding every object in the world, i already worked with Flash CS5 and it was a bit easy adding Movie Clips to the stage, now it’s different with FlashDevelop, Thank You.
Handling Multiple Objects
I don’t think i understood the question.
FlashPunk works with Worlds and Entities. Each lvl is a World and every object is an Entity. You can add an entity in a world using:
world.add(entity);
If you want to generate objects with code you can create new entities (you can extend the class) and add them to a world at any time.
Yes actually what i meant is that i have a lots of assets, level backgrounds, images of rocks, and i have to add them all to my world, i created entities and now every time i want to add it i must use world.add(entity) and sometimes i have to repeat that for the some entity but for different positions, i was wondering if that’s what i should do ?
It will depend of the type of game you are making. Thinking about it i think you have 3 options (you can actually mix of them):
- Add everyithing manually.
- Use a data Array. Basically an Array with all the objects with the data needed.
- A usual option is to save the levels in external files and make a “Level” class that extend World and is able to load them. Is even a better system if you have more than a single level. (use of XML is a good exaple)
Personally i like the last one becouse you can use the same code for ANY other level you want to make.
PD: I don’t know if there is any program to make that easier.
… I appreciate the feed back and i think i’ll like the third option as well, if you have any examples using external files that would be awesome
You’re welcome! If you’ve never used XML before, I’d also recommend going over the basics: http://www.republicofcode.com/tutorials/flash/as3xml/