public synchronized void removeAll() { if (sprites != null) { sprites.removeAll(); } if (desktop != null) { desktop.getContentPane().clear(); } }
public final void paint(LGraphics g) { if (!running || isClose()) { return; } if (sleep == 0) { if (scrCG == null) { return; } if (scrCG.getBackgroundCG() != null) { if (shakeNumber > 0) { g.drawImage( scrCG.getBackgroundCG(), shakeNumber / 2 - LSystem.random.nextInt(shakeNumber), shakeNumber / 2 - LSystem.random.nextInt(shakeNumber)); } else { g.drawImage(scrCG.getBackgroundCG(), 0, 0); } } int moveCount = 0; for (int i = 0; i < scrCG.getCharas().size(); i++) { Chara chara = (Chara) scrCG.getCharas().get(i); float value = 1.0f; if (chara.next()) { value = chara.getNextAlpha(); moveCount++; } g.setAlpha(value); chara.draw(g); g.setAlpha(1.0F); } drawScreen(g); if (desktop != null) { desktop.createUI(g); } if (sprites != null) { sprites.createUI(g); } } else { sleep--; if (color != null) { double alpha = (double) (sleepMax - sleep) / sleepMax; if (alpha < 1.0) { if (scrCG.getBackgroundCG() != null) { g.drawImage(scrCG.getBackgroundCG(), 0, 0); } g.setAlpha(alpha); g.setColor(color); g.fillRect(0, 0, getCurrentWidth(), getCurrentHeight()); g.setAlpha(1.0f); } } if (sleep <= 0) { sleep = 0; color = null; } } }
/** 创建程序UI */ public synchronized void createUI(final LGraphics g) { draw(g); if (sprites != null) { sprites.createUI(g); } if (desktop != null) { desktop.createUI(g); } }
public void run() { initAVG(); while (running) { repaint(); pause(delay); if (desktop != null) { desktop.update(delay); } if (sprites != null) { sprites.update(delay); } } }
public void pointerPressed(double x, double y) { if (desktop != null) { LComponent[] cs = desktop.getContentPane().getComponents(); for (int i = 0; i < cs.length; i++) { if (cs[i] instanceof LButton) { LButton btn = ((LButton) cs[i]); if (btn != null && btn.isVisible()) { if (btn.intersects((int) x, (int) y)) { btn.doClick(); } } } else if (cs[i] instanceof LPaper) { LPaper paper = ((LPaper) cs[i]); if (paper != null && paper.isVisible()) { if (paper.intersects((int) x, (int) y)) { paper.doClick(); } } } } } click(); }
public void removeAll() { sprites.removeAll(); desktop.getContentPane().clear(); }
public void remove(LComponent comp) { desktop.remove(comp); }
public void add(LComponent c) { if (desktop == null) { initDesktop(); } desktop.add(c); }
public synchronized void remove(LComponent comp) { if (desktop != null) { desktop.remove(comp); } }
/** * 添加游戏组件 * * @param comp */ public void add(LComponent comp) { if (desktop != null) { desktop.add(comp); } }
/** 触发输入事件 */ public void changeText(String text) { desktop.changeText(text); }
/** * 检查窗体默认对象中是否包含指定组件 * * @param comp * @return */ public boolean contains(LComponent comp) { return desktop.getContentPane().contains(comp); }