How to minish the main swf file in ActionScript in flash game development
Question about flash game development. One game has lots of modules. In flex one module is a SWF file. But I don't know how can I partition the module in AS3. For example, my main SWF file is 10M, you know it's to big. I want to divide it i开发者_JAVA技巧nto several parts.
I'm not completely sure what you are asking, but I think it comes down to what your game is comprised of. What is taking up that 10MB ? If you have different music for each level, then I would suggest only loading music at the beginning of the level. If you have artwork/animations that is specific to a level, then I'd load only what is needed for that level.
You need to decide what it is that isn't needed all the time, and then sort that list by memory and target the bigger ticket items. I can't imagine you have even 1MB of game logic, most of that 10MB has to be content based.
You could fragment your application into a few different SWFs and load them in when required (assuming that each SWF is able to function on its own). Images/sounds/videos etc can also be loaded in separately. It's hard to tell how you can achieve a fragmented application without any knowledge on the application itself, but this is about the only way I can think of.
Maybe something along these lines:
- Main Menu SWF
- Game Logic SWF
Also, to make the initial load of the file quick, you could prioritise your assets based on what order they appear in the game. Keep all your "must" assets as priority 1 and load these at the preloader:
- Menu
- Game Logic
- HUD assets
- Game over
- Basic level graphics
Then priority 2 could be things that aren't actually required to play (like fancy graphics, music)
- Tile graphics for walls and stuff (could use solid colours until these load)
- Music/sounds
- Backgrounds
- Fancy effects
You could dispatch an event as each thing is loaded that loads the graphics onto each of the already loaded tiles (if any), stuff like that.
Priority 3 can be stuff that you don't see until end-game, extras, credits, etc.
Separate your game into different files to make it more structured and easier to load. LoaderMax has some really nice loading functionality.
http://www.greensock.com/loadermax/
http://www.greensock.com/loadermax-tips/
Example of structure:
- Main.swf
- LevelSelector.swf
- Intro.swf
- Level.swf
- HudAssets.swf
- LevelAssets.swf
- Outro.swf
精彩评论