⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 help.java

📁 很不错的泡泡堂手机游戏
💻 JAVA
字号:
/*
 * 创建日期 2007-4-1
 * @author caipiz
 * 由源码爱好者_www.codefans.net整理下载
 */
package com.cpiz.poptang;

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

/**
 * 帮助及关于类
 * @author caipiz
 */
public class Help extends Canvas
{
    PopTang midlet = null;
    Displayable dis = null;
    StringLayout sl = null;
    int width, height;
    int anchorX, anchorY;
    Font font = null;
    String str = null;
    String strTitle = null;
    
    /**
     * 构造参数,表示构造“帮助”界面
     */
    public static final int HELP = 0;
    
    /**
     * 构造参数,表示构造“关于”界面
     */
    public static final int ABOUT = 1;
    
    public Help(int type, PopTang midlet, Displayable dis)
    {
        this.midlet = midlet;
        this.dis = dis;
        this.setFullScreenMode(true);
        
        width = getWidth();
        height = getHeight();
        anchorX = (width - PopTang.GAME_WIDTH) / 2;
        anchorY = (height - PopTang.GAME_HEIGHT) / 2;
        
        switch(type)
        {
        case HELP:
            strTitle = PopTang.HELP_TEXT[0];
            str = PopTang.HELP_TEXT[1];
            break;
        case ABOUT:
            strTitle = PopTang.ABOUT_TEXT[0];
            str = PopTang.ABOUT_TEXT[1];
            break;
        default:
            strTitle = PopTang.ABOUT_TEXT[0];
            str = PopTang.ABOUT_TEXT[1];
            break;
        }
        
        font = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL);
        sl = new StringLayout(str, anchorX, anchorY, PopTang.GAME_WIDTH, PopTang.GAME_HEIGHT - font.getHeight() - 2, 2, font);
    }
    
    protected void paint(Graphics g)
    {
        // 清屏
        g.setColor(PopTang.HELP_BGCOLOR);
        g.fillRect(anchorX, anchorY, PopTang.GAME_WIDTH, PopTang.GAME_HEIGHT);
        
        // 绘制标题
        g.setColor(0x000000);
        g.drawString(strTitle, width / 2, anchorY, Graphics.TOP | Graphics.HCENTER);
        g.drawLine(anchorX + 20, anchorY + font.getHeight() + 1, anchorX + PopTang.GAME_WIDTH - 20, anchorY + font.getHeight() + 1);
        
        // 绘制内容
        g.setColor(PopTang.COLOR_YELLOW);
        sl.draw(g, anchorX, anchorY + font.getHeight() + 6);
        
        // 在屏幕右下方绘制提示     
        g.setColor(0x000000);
        g.drawString(PopTang.HELP_TIP, getWidth() - 2 - anchorX, getHeight() - 2 - anchorY,
                Graphics.RIGHT | Graphics.BOTTOM);
    }
    
    protected void keyPressed(int key)
    {
        switch(key)
        {
        case -2:
            sl.next();
            repaint();
            break;
        case -1:
            sl.prev();
            repaint();
            break;
        default:
            back();
            break;
        }
    }
    
    /**
     * 返回到上一屏幕
     *
     */
    private void back()
    {
        midlet.setDisplayable(dis);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -