J2ME应用程序菜单开发

发布于 2024-12-02 20:20:12 字数 496 浏览 2 评论 0原文

我正在开发一个小型 j2me 游戏,我想为此应用程序创建一个菜单。我将菜单想象为一个垂直的项目列表,光标位于左侧或右侧,我可以从一个项目移动到另一个项目,就像这样 菜单示例,但作为主菜单。 我应该使用哪些元素才能获得这样的效果?我只需要建议或链接,我会自己开发。

提前致谢!

import java.util.Vector;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

I'm developing a small j2me game and i want to create a menu for this application. I imagine the menu as a vertical list of items with a cursor on the left or right side that i can move from item to item, something like this menu example but as a main menu.
What elements should i use to obtains such effects? I need only advices or links, i will develope it myself.

Thanks in advance!

import java.util.Vector;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苍风燃霜 2024-12-09 20:20:12

你的计划看起来是可行的。无法提供太多链接,因为不记得任何对您正在做的事情有帮助的链接。实际上,对您来说最有用的链接可能是 MIDP (JSR 118) API 参考 - 您的部分将主要是 lcdui 包,尤其是 Graphics API。

至于建议,没问题。首先要注意的是,与您之前使用隐式列表进行的实验相比,将会有更多的编码和更多(更多)的测试/调试。如果您能想到一些可能成为问题的截止日期/时间要求 - 请记住先前的设计以隐式列表作为后备。它看起来不会那么花哨,但它会安全、正确地工作。

另一件重要的事情是决定您的目标设备类型。对于像您要开发的菜单这样的菜单,在 160x200 基本手机上使用 ITU-T 键盘 和 400x600 触摸屏智能手机。下面我将假设您将尝试针对尽可能广泛的设备 - 请注意,您可以获得的范围越窄,编码和测试就越容易。

当针对许多不同的设备时,使用可配置为模拟各种显示尺寸和分辨率、是否存在触摸屏输入等的模拟器会很有帮助。请记住,仅靠模拟器并不能完全模拟真实设备。为了脚踏实地,还可以考虑使用真实设备对您的应用程序进行一些常规的冒烟测试,最好使用无线 (OTA) 安装。

以下是我现在能想到的一些特定的 API 技巧。

  • 使用 Canvas.getGameAction 来处理按键代码 - 这可能是向上/向下计算和选择菜单操作的最可靠/可移植的方法。
  • 使用 Canvas.hasPointerEvents 确定是否支持触摸屏。如果使用触摸屏设备的用户发现您的精美菜单在点击屏幕时无法做出反应,可能会感到失望。
  • 使用 Font.getHeightFont.stringWidth 计算菜单项文本占用了多少空间。
  • 如果您想在图像对象上绘制某些内容,请使用Image.getGraphics

正如我提到的,您很可能会使用 lcdui.Graphics API 做很多事情。它大多相当简单,但您可能需要了解有关剪辑的一些棘手的内容。祝你好运。

What you plan looks doable. Can't give much links because don't recall any that could help on stuff like you're doing. Actually, most useful link for you will probably be MIDP (JSR 118) API reference - your part is going to be mostly lcdui package, and especially Graphics API.

As for advice, no problem. First thing to note is that there will be more coding and more (much more) testing/debugging than it was in your prior experiment with implicit list. If you can think of some possible deadline / timing requirements that may become a problem - just keep in mind that prior design with implicit list as a fallback. It won't look as fancy but it'll work work safe and correct.

Another important thing is to decide what kind devices you are going to target. For menu like one you are going to develop, it may be rather difficult to get consistent look and feel both at 160x200 basic phone with ITU-T keypad and on 400x600 touchscreen smartphone. Below I am going to assume you'll try to target as wide variety of devices as possible - note the narrower you can get it, the easier it will be to code and test.

When targeting lots of different devices it is helpful to use an emulator that can be configured to simulate various display sizes and resolution, presense or absence of touchscreen input etc. Keep in mind though that emulator alone won't fully simulate real device. To keep your feets on the ground, consider also some regular smoke testing of your application with real device, preferable using over-the-air (OTA) installation.

Here are some particular API tips that I can think of now.

  • Use Canvas.getGameAction to handle pressed key code - that is likely the most reliable/portable way to figure up/down and select actions for menu.
  • Use Canvas.hasPointerEvents to figure if there's touch screen support. Users with touch screen devices may get disappointed if it turns out that your fancy menu can't react when they tap on screen.
  • Use Font.getHeight and Font.stringWidth to figure how much space is occupied by menu item text.
  • Use Image.getGraphics if you want to draw something over the image object.

As I mentioned, you most likely will do a lot of stuff using lcdui.Graphics API. It's mostly rather simple, but you will probably need to understand somewhat tricky stuff about clipping. Good luck.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文