Solve the problem of mobile game transplant on J2ME platform

Source: Internet
Author: User
Tags resource what interface

The main job of mobile game transplant is to put the original one of the other models on the phone game. A process that can be modified to run and use on a mobile phone of the current model. So it can be divided into several aspects of the work:

1, processing screen size

This is also the most important point. Different models of mobile phones. The screen size is different. The resolution is different. So make sure each game on each type of mobile phone can achieve the same effect. That's really a difficult thing to do. So when you transplant, try to find a smaller gap in the model to do the transplant. What you need to notice in the program is the size of the double buffering. And the position of the picture content. Of course the most willing to see is to have a global variable to control the entire game scene.

2. Modify Key value

This is another important aspect. A prerequisite for making sure that the game is operating properly. For example, Nokia's model of the left and right soft key is -6,-7, and Motorola's C650 of the soft key is -21,-22. So the difference is unavoidable. Unless your mobile game program can adapt to different models to produce different key values. That's what I did in a game last month. and adapt to different screen sizes. Yes, it's a good procedure.

3, processing memory footprint

This is another question that cannot be avoided. If your phone has a good performance. Then maybe you don't have to think about it. Like you do the Motorola E680 game. But the memory capacity of most models is what you need to focus on. I've seen many games that are difficult to explain when porting to new models. are generally caused by insufficient memory. For example, pictures cannot be displayed. The game cannot be installed. Crash and other phenomena. So we're in the process of transplanting. You need to calculate your memory footprint beforehand. Sets the useless object to null.

4. Complete Chinese

Some games are in English interface. So if you want to comply with China Mobile's norms to do. You must also ensure that no English characters appear. But that sounds a little too pushy. For example, in the game of the lap 1/3 circuit in the first few laps. You have to change into circle 1/3. But there is no way. Compliance is a prerequisite for you to submit the game. The problem that may arise in the process of Chinese is. If the text is made into a picture, you need to help with the art to complete the work.

5, the function of the game modification

Many times if you want to keep the same rules as China moves. You need to modify the location of the left and right function keys. And also involves adding pause and continue functionality to the game. There are even times when you need to write a game menu yourself. and add some logo interface.

The aspects mentioned above. Most of the work that must be done in a transplant. If you run into a game that's hard to get you to do. Don't worry. Because the code is not written by you. If you look dizzy, you can start with the simple. Then sort out the idea. Let's talk about the general steps in the transplant process.

1. View resource Files

That's the most important thing. Is the prerequisite for you to modify the game. If you don't know what a resource file is, you can't do the rest of the work. There are several resource files. Like a simple picture. PNG format (the Japanese DoJa game picture format is GIF), sound files, text files, data files, and so on. Here's a reference to the data file. Generally put in addition to pictures, sounds, text formats other than the file are called data files. But this kind of document is I do not want to see. Because it is not easy to modify with. Some games are convenient for reading resources. and occupy space for consideration. The picture file will be made into a data file to be processed. It used to be ultraedit to open this data file. Then a passage of data from the PNG format is extracted. Then save the new file as a PNG. Very troublesome. Then two tools were written. A program is used to extract pictures. A program is used to generate a new data file. It's a lot easier to feel.

2, reading the Code skills

The code must be read. Otherwise it is not called modified. But you don't have to read and read through. And not every sentence to see the whole, if tens of thousands of lines of code. You read every sentence. It's enough for you to be tired. And can not be completed within the time specified by the boss. You're in trouble, too. I generally first want to see the game to achieve the main scene and function of the class. Which is called the canvas class. Because this class is definitely not started by itself. To load through the MIDlet main class. Or it's a little more tactful. Load through another class. So all the other classes are supporting this class to complete the game function. Then look at which packages the class was imported. Inherit from what class. What interface was implemented. And then look at its constructor. and the Paint () method. If you have a thread, look at the code inside the Run (). These are the main points of entry for this game. Controls the process and drawing of the game. Other things like algorithms in the game. If there is time. You'll have a good look. It means a lot to you.

3, do not believe the simulator

Do different brands of mobile phones, different models of mobile games, will certainly use the simulator to run. Look at the effect. The word "effect" is already very pertinent. Because some game simulators are not running. You can't even see the effect. So it has to be run and tested with a real phone. But the key value must also be measured with the real machine. Although most simulators are the same as the corresponding real machines.

4, solve the different mobile phone bugs

This is the most troubling thing. There will be some inexplicable mistakes. It's very good to run on this phone. But there was an unexpected error on the other phone. such as inability to install. The picture cannot be displayed. Play to a place to crash. Sound can't play and so on. Don't worry before you get into trouble. Calmly recall the code and the last modification process. If all are ruled out for human reasons. Then consider it from memory and pictures. Sometimes repaint () and servicerepaints () also have problems. Like Nokia's new S60 system. and consider the problem not too one-sided. Because the game itself is a interlocking process.

In addition to talk about the processing of mobile phone memory. This is a classic topic. What string to use, System.GC () and the like. and set the useless object to null. All of these online discussions are relevant. and the static usage. Mention a place. is when the phone loads the picture. Mobile phone calculation of the memory occupied by: Picture length x picture width x picture color number x2. Even a transparent picture and a monochrome image of the same size occupy a very close memory. Also use less graphics.drawstring (). Have time to write your own program test. If you write a piece of text. Use n this statement. Then you should see it. Whether you want to replace it with a string array. Or make pictures that take up less memory.

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.