计算机游戏7步变28,计算机毕业论文 游戏

本文讨论了如何优化MIDlets(移动设备上的Java应用程序)。通过减少每个字节数据的成本,使用混淆器来压缩不必要的信息,使JAR文件更小。虽然混淆器对MIDlets的保护作用有限,但可以显著减小文件大小,平均可减少10%。此外,建议考虑只使用必要的库,合并图像文件以减少资源占用,并确保资源尽可能小且精简。
摘要由CSDN通过智能技术生成

bytes (?static byte[] data = {(byte)0x02, (byte)0x4A, …};’) costs 4 bytes per value, not 1 byte, in the resulting class file.

2.2 Using an obfuscator

An obfuscator is a program that modifies your compiled Java program to remove all unnecessary information (like long method and variable names), making it hard to understand the result of ―decompiling‖ it. As a protection method it is of less value for MIDlets, since they‘re so small that with some work even a decompiled obfuscated MIDlet can be figured out.

However, removing all of that unnecessary information makes your JAR file smaller, which is very helpful. The size reduction varies from obfuscator to obfuscator and from MIDlet to MIDlet, but tests on a few of our own MIDlets showed that a 10% reduction is typical. This is less than usually claimed for obfuscators, perhaps because MIDlets are small and there are some fixed overheads, and also because resources like PNG bit map files make up a larger proportion of a MIDlet‘s JAR file.

2.3 Libraries

In normal software development it is wise to develop and use libraries of frequently needed functionality. However, if the entire library is included in your MIDlet suite, you‘re likely to be paying for a lot of functionality you don‘t actually n eed.

You may do better to fall back on ―cut and paste‖ reuse. It is a less efficient use of a developer‘s time, but a more efficient use of the JAR file space.

If you do use libraries, consider whether you need all the classes in the library. Perhaps you can remove several of the class files. You may even want to recompile some classes with unused methods removed.

Bearing this in mind, if you‘re writing a MIDP library you should aim to reduce dependencies between classes, so that unneeded classes can indeed be safely removed. Unfortunately, one typical approach to this is to use Java interfaces, which again expands your library size

2.4 Keeping resources small

MIDlet suites often contain associated PNG bit maps, etc. Keep these as small and as few as possible.

There are significant differences in the size of a PNG bit map when saved with different bit map editing tools — not all optimize for size. Try a few of these tools and save with whichever gives the smallest result (even if you prefer to edit with another).

2.5 Combining image files

Just as it helps to minimize the per-file JAR overhead by having as few classes as possible, it also helps to have as few image files as possible. One often-used trick is to combine many images into one file:

Once that large image has been loaded from the file, individual frames can be drawn as follows:

g.setClip(x, y, FRAME_WIDTH, FRAME_HEIGHT); g.drawImage(fiveMenImage, x –FRAME_WIDTH * frameNumber, y, Graphics.TOP | Graphics.LEFT);

Here frameNumber is from 0 to 4; by cycling it in the sequence {0, 1, 2, 3, 4, 3, 2, 1} you will produce an animation of a walking man. If you do any more drawing in your paint method after the

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值