A Journey to the West rich web version has also been inside for nearly a month, this time bug constant tinkering has not stopped though, but did not call earlier so busy. Development of online games is nearing 1 year web, and not much of experience, hard to write something, the only long-winded point is simple, casual regaling project development in some of the details of it, be under the sharing of experience.
1. On the configuration file management. Here are 2 methods:
a. hard-coded in a class as static methods available.
Advantages: high efficiency. Disadvantages: trouble updating it, modify the configuration files have to recompile a project.
b. For more configuration files, and modify the frequent items can take all the configuration files are packaged into a swf file, a class corresponds to a configuration file, in the document class provides these configuration classes call interface, so that the initial of the time also need to load a swf file, and capacity than the overall xml
Files are also much smaller, which also maintained to facilitate future updates.
General projects are used to combine the two. Here only scratch the surface of the offer a few ideas only.
2. On the rational use of resources. Because now flash's garbage collection soon to be tired, so here are some of the project is strongly recommended as far as possible reuse of resources, there are two ideas.
a. such as props in the game, basically a picture, for those unique components, such as equipment, field, ensure that only one instantiation, so that you can order a unique window as a resource pool, will add save the picture to set off a dictionary, when there is no corresponding picture in the dictionary when it is loaded. The advantages of doing so: 1> can be reduced and the number of save bandwidth connection to the server, 2> to reduce the image to load, so as little as possible of the lower frequency of garbage collection. Disadvantages: do so, the memory footprint will be relatively large, this can be based on project needs, and props such as pictures, are relatively small, basically using this method, a reminder, this time to clean up the data cache is more important.
b. This method is similar to the skin in the treatment of the flex. Reused many times and all the pictures of smaller capacity packed into a swf, the picture for each resource (
This includes not only pictures, it can be some animation mc, etc.) corresponds to a link name, the project called, the map is a Class
So you can only load a resource bundle to be inexhaustible resources corresponding to the call, this method is appropriate for those vector animation. The basic advantages and disadvantages above, a drawback is the added trouble of comparing this method, more resources, then the workload may increase a lot.
Of course, the premise of using these two methods is that when you care about memory usage situation, and ignore the garbage collection performance impact caused by short (ms
Now there is little abnormal player10 garbage collection), and references to determine some of the resources can be cleared for garbage collection after the above two methods ws.
3. On the registered event listener code. There seems to be winded, but still speak out of turn one plug, must remember to do the event listener
remove away, when the project bigger, when resources do not you worry be recycled, you think of the vast amounts of code to find those references not being cleared away, you will feel the pain of the needle in the haystack. Of course, the event listener is a reference to the situation, but this is only done small projects most likely to be ignored after a problem, the last sentence, the most important programming practice.
4. For external loaded swf, the scene in the animation when the play came after the conclusion of loading must remember to stop off the animation plays, flash9 exported animation will automatically repeat, if not remove the swf animation garbage collected, those who repeat the animation though not in front of you beat, but it is still for you to seize the cpu, when you find that there is no animation in the display interface, and no complex logic in dealing with the time found that when regular high cpu when low, to think about this situation it. I was once this injury previously found that did not do any computing time
cpu will actually run intermittently for about 30%, before the thought was forgotten where writing stopped the timer, the strenuous effort for even those who only discovered the remains in memory swf animation to engage in prank, really depressed for some time.
Wow, found that the night was deep, nagging them to be right, have no difficulty, in fact, some of the details in the project development summary only, personal view is that the algorithm for the project logic, in fact sort out the ideas, look up Data can be solved out, decided to develop a project schedule is actually the most easily overlooked details, and these will need to continue the accumulation of experience summed up. I wish I could give you a summary of some help.