Lazy Download resources and call examples in Java games

Source: Internet
Author: User
Tags mixed

To be honest, delayed downloading of game resources and calls is only an auxiliary means, with the game development itself is not very much, the essence is nothing more than file download and file read mixed use. But given last week, a netizen asked about such a problem, the author felt that with a separate interpretation of the mail, rather than write a blog to look more specific and clear, but also to help the author treatise, so that the article, for reference only.

Generally speaking, we will need to download the game resources to load, but for the following purposes:

1. Simplify the game volume:

Suppose I do a 100MB game, but I do not want to advertise it as only 1MB of the smart program, then what should I do?

To deceive users, using a lot of sophisticated technical terminology to fool them to say 1MB and 100MB equivalent? Users are not fools, at least not all fools, no matter how clever your words, it is difficult to make most people believe that 1MB and 100MB are the same. But the boast has been exported, always to find a way to solve.

In fact, in the existing technology system, to get them good simple, just the game initial interface mixed download packaging into 1MB file release, and then "cheat" they download execution, and then--let them slowly wait for the system to load the remaining 99MB bar! After all, no one has said that this game does not require additional network resource synchronization ...

2, the online game resources delay loading needs:

Current online games-especially web games, in order to minimize unnecessary resource wastage and improve operational efficiency, most of the time will not load all resources into the game, but "Grand, Divide and conquer", the game resources are built into a small bundle of resources, only when needed, only or synchronous, or asynchronously loaded into the game. This is what we have seen in a lot of online games, when the role of the screen, read new maps or encounter new monsters, the screen will appear in the words or some mosaic or even pause reasons.

Therefore, through the network timely to load the required resources, almost has become an essential skill in the development of online games.

3, into a special encryption and decryption mechanism:

We all know, but no one can decipher the procedure that any man has made. But--it is very likely that one person can do the procedure, another phenomenon that cannot be cracked within a year. And when a few years later, the other person to crack out, this procedure is already over gas, white send no one wants.

So, when you don't want to reverse-engineer your own game-especially if you want to protect Java's excellent decompile code, another sense of downloading through the web is evident. You can save the downloaded jar or class and so on to a "stealth" site different from the execution directory, and regardless of the key or special structure, in short, the change of the source of the encryption of resources to confuse, even if you do not know what this is not what it is-can be interpreted as a byte code is good, Maximum increase in reverse difficulty. And when you're done, just delete it--next time you can. To do so, although not completely eliminate the code by others to steal, but, at least can let the reverse of my code that buddy tired Skin (^^).

4, local procedures and legal verification of resources:

In most online games, in order to ensure that users do not make some such as the use of plug "foul" behavior, it will be the system environment and even packet data for legality verification, and once found that "illegal" things exist, will make "illegal" players puppet or simply to punish.

However, these validations are mainly for the program "external", that is, when the "foul" object "is not my game" can play a role, but in case the "foul" "from the game itself" or "the verification program that comes from the game itself", then become powerless, which is why most of the online games are "hung" the spread of the cause.

Fortunately, the Java program, because of its "talent limit", it is difficult to use the outside of the virtual machine, if the use of Java to make online games, in principle, can not worry about the "hanging" problem-but, this also has a major premise, that is, in the "hang" running outside the virtual machine to the pass.

And what if "hang inside" is running within the virtual machine? What if my "hang inside" is a small piece of code inserted into the original game? You know, dynamically loading class, dynamically modifying bytecode, has long been a little bit of a thing.

At this point, you need to verify the legality of the Java program.

It is time-consuming to verify this, but if we are good at using each download resource (larger, such as a map or game update), if not just "download", More Synchronous "uplink", using the blank file with the server to proofread the legality and integrity of local Java programs, To a large extent to avoid this meaningless check time waste. At this time there are missing files added, there is superfluous--that is, the existence of the jar or class and even the original bytecode modification, it will be forced to "click" Off it, lest it "for the world."

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.