Java 类org.newdawn.slick.gui.MouseOverArea 实例源码

项目:code404    文件:Menu.java   
@Override
public void init(GameContainer gc, StateBasedGame sbg)
        throws SlickException {

    background = new Image("res/background.png");

    x = gc.getWidth();
    loadingThread = new MenuLoadingThread();

    subscriptions = new ArrayList<LevelCard>();

    logo = new Image("res/logo.png");
    logo.setFilter(Image.FILTER_NEAREST);
    logo = logo.getScaledCopy(3f);

    back = Main.loadImage("res/login.png");

    exit = new MouseOverArea(gc, Main.USEFUL_BUTTONS.getSprite(0, 3), 4, 4);
        exit.setMouseDownImage(Main.USEFUL_BUTTONS.getSprite(1, 3));
    mute = new MouseOverArea(gc, Main.USEFUL_BUTTONS.getSprite(0, 5), 44, 4);
        mute.setMouseDownImage(Main.USEFUL_BUTTONS.getSprite(1, 5));
    left = new MouseOverArea(gc, Main.USEFUL_BUTTONS.getSprite(0, 1).getFlippedCopy(true, false), gc.getWidth() / 2 - 190, gc.getHeight() / 2 + 4);
        left.setMouseDownImage(Main.USEFUL_BUTTONS.getSprite(1, 1).getFlippedCopy(true, false));
    right = new MouseOverArea(gc, Main.USEFUL_BUTTONS.getSprite(0, 1), gc.getWidth() / 2 + 158, gc.getHeight() / 2 + 4);
        right.setMouseDownImage(Main.USEFUL_BUTTONS.getSprite(1, 1));
    add = new MouseOverArea(gc, Main.USEFUL_BUTTONS.getSprite(0, 6), gc.getWidth() / 2 + back.getWidth() / 2 - 40, gc.getHeight() / 2 + back.getHeight() / 2 - 20);
        add.setMouseDownImage(Main.USEFUL_BUTTONS.getSprite(1, 6));

    play = new MouseOverArea(gc, Main.BIG_BUTTON.getSprite(0, 0), gc.getWidth() / 2 - 64, gc.getHeight() / 2 + back.getHeight() / 2 + 52);
        play.setMouseDownImage(Main.BIG_BUTTON.getSprite(0, 1));
    levels = new MouseOverArea(gc, Main.BIG_BUTTON.getSprite(0, 0), gc.getWidth() / 2 - 64, gc.getHeight() / 2 + back.getHeight() / 2 + 92);
        levels.setMouseDownImage(Main.BIG_BUTTON.getSprite(0, 1));
}
项目:code404    文件:LoginScreen.java   
@Override
public void init(GameContainer gc, StateBasedGame sbg)
        throws SlickException {

    background = new Image("res/background.png");

    back = Main.loadImage("res/login.png");

    sheet = new SpriteSheet(Main.loadImage("res/textbox.png"), 256, 32);

    user = new MouseOverArea(gc, sheet.getSprite(0, 0), gc.getWidth() / 2 - 128, gc.getHeight() / 2 - back.getHeight() / 2 + 65);
        user.setMouseOverImage(sheet.getSprite(0, 1));
        user.setMouseDownImage(sheet.getSprite(0, 1));
    password = new MouseOverArea(gc, sheet.getSprite(0, 0), gc.getWidth() / 2 - 128, gc.getHeight() / 2 - back.getHeight() / 2 + 115);
        password.setMouseOverImage(sheet.getSprite(0, 1));
        password.setMouseDownImage(sheet.getSprite(0, 1));
    go = new MouseOverArea(gc, Main.USEFUL_BUTTONS.getSprite(0, 1), gc.getWidth() / 2 + back.getWidth() / 2 - 40, gc.getHeight() / 2 + back.getHeight() / 2 - 40);
        go.setMouseDownImage(Main.USEFUL_BUTTONS.getSprite(1, 1));
    register = new MouseOverArea(gc, Main.BIG_BUTTON.getSprite(0, 0), 4, gc.getHeight() - 40);
        register.setMouseDownImage(Main.BIG_BUTTON.getSprite(0, 1));

    errorImage = Main.loadImage("res/error.png");

    this.connect = new LoginScreenConnectThread();

    gc.getInput().addKeyListener(new LoginScreenKeyListener());

}
项目:code404    文件:Game.java   
@SuppressWarnings("unchecked")
@Override
public void init(GameContainer gc, StateBasedGame sbg)
        throws SlickException {

    errorImage = Main.loadImage("res/error2.png");

    lastMouseX = gc.getInput().getAbsoluteMouseX();
    lastMouseY = gc.getInput().getAbsoluteMouseY();

    gc.setMouseCursor(Main.CURSOR_IMAGES.getSprite(1, 0), 16, 16);

    FONT = new UnicodeFont("res/Anonymous_Pro.ttf", 12, false, false);

    FONT.addAsciiGlyphs();
    FONT.getEffects().add(new ColorEffect());
    FONT.loadGlyphs();

    coin = Main.loadImage("res/coin.png");

    EditorKeyListener listener = new EditorKeyListener(this);
    gc.getInput().addKeyListener(listener);

    tiles = new SpriteSheet(Main.loadImage("res/tiles.png"), 32, 32);

    play = new MouseOverArea(gc, Main.USEFUL_BUTTONS.getSprite(0, 1), 4, gc.getHeight() - 40);
        play.setMouseDownImage(Main.USEFUL_BUTTONS.getSprite(1, 1));
    stop = new MouseOverArea(gc, Main.USEFUL_BUTTONS.getSprite(0, 2), 44, gc.getHeight() - 40);
        stop.setMouseDownImage(Main.USEFUL_BUTTONS.getSprite(1, 2));
    help = new MouseOverArea(gc, Main.BIG_BUTTON.getSprite(0, 0), 84, gc.getHeight() - 40);
        help.setMouseDownImage(Main.BIG_BUTTON.getSprite(0, 1));
    failed = new MouseOverArea(gc, Main.USEFUL_BUTTONS.getSprite(0, 3), gc.getWidth() / 2 - 16, gc.getHeight() / 2 + 40);
        failed.setMouseDownImage(Main.USEFUL_BUTTONS.getSprite(1, 3));
    pause = new MouseOverArea(gc, Main.USEFUL_BUTTONS.getSprite(0, 0), 8, 8);
        pause.setMouseDownImage(Main.USEFUL_BUTTONS.getSprite(1, 0));

    menu = new MouseOverArea(gc, Main.BIG_BUTTON.getSprite(0, 0), gc.getWidth() / 2 - 64, gc.getHeight() / 2 + 16);
        menu.setMouseDownImage(Main.BIG_BUTTON.getSprite(0, 1));

    SpriteSheet sheet = new SpriteSheet(Main.loadImage("res/tweet.png"), 128, 32);

    tweet = new MouseOverArea(gc, sheet.getSprite(0, 0), gc.getWidth() / 2 - 64, gc.getHeight() / 2 + 56);
        tweet.setMouseDownImage(sheet.getSprite(0, 1));
    scores = new MouseOverArea(gc, Main.BIG_BUTTON.getSprite(0, 0), gc.getWidth() / 2 - 64, gc.getHeight() / 2 + 96);
        scores.setMouseDownImage(Main.BIG_BUTTON.getSprite(0, 1));

    coins = 0;

    arrow = Main.loadImage("res/arrow.png");

}
项目:code404    文件:EditorPane.java   
public EditorPane(Game game, GameObject target, GameContainer gc) throws SlickException {

    String[] script = target.getScript().split("\n");

    for (int i = 0; i < script.length; i++) {

        currentScript.add(script[i]);
    }

    target.setScript(this.getCurrentScript());

    this.game = game;
    this.object = target;
    this.buttons = new SpriteSheet(Main.loadImage("res/buttons.png"), 24, 24);

    exit = new MouseOverArea(gc, buttons.getSubImage(0, 1), (int) Math.ceil(gc.getWidth() - (targetWidth - 10)), gc.getHeight() - 32);
        exit.setMouseOverImage(buttons.getSubImage(1, 1));
        exit.setMouseDownImage(buttons.getSubImage(2, 1));

}
项目:ESCP    文件:CheckBox.java   
/**
 * creates moa with a default picture used simply to get right bounds.
 */
private void createMoa() {
    moa = new MouseOverArea(guiContext, boxImg, xPos, yPos);
}
项目:ESCP    文件:Button.java   
/**
 * Create a new button with one default, one hover and one pressed image.
 * 
 * @param guiContext
 *            the container.
 * @param image
 *            the default image used. Also gives size of moa.
 * @param moImage
 *            the picture displayed when hovering.
 * @param mdImage
 *            the picture displayed when button pressed.
 * @param x
 *            x coordinate for button upper left corner.
 * @param y
 *            y coordinate for button upper left corner.
 */
private Button(GUIContext guiContext, Image image, Image moImage,
        Image mdImage, int x, int y) {
    this.guiContext = guiContext;
    mouseOverArea = new MouseOverArea(guiContext, image, x, y);
    mouseOverArea.setMouseOverImage(moImage);
    mouseOverArea.setMouseDownImage(mdImage);
    this.buttonActive = true;
}