本文整理匯總了Java中org.newdawn.slick.Graphics.setWorldClip方法的典型用法代碼示例。如果您正苦於以下問題:Java Graphics.setWorldClip方法的具體用法?Java Graphics.setWorldClip怎麽用?Java Graphics.setWorldClip使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.newdawn.slick.Graphics
的用法示例。
在下文中一共展示了Graphics.setWorldClip方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: render
import org.newdawn.slick.Graphics; //導入方法依賴的package包/類
/**
* @see org.newdawn.slick.Game#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
*/
public void render(GameContainer container, Graphics g)
throws SlickException {
g.setColor(Color.white);
g.drawString("1 - No Clipping", 100, 10);
g.drawString("2 - Screen Clipping", 100, 30);
g.drawString("3 - World Clipping", 100, 50);
if (world) {
g.drawString("WORLD CLIPPING ENABLED", 200, 80);
}
if (clip) {
g.drawString("SCREEN CLIPPING ENABLED", 200, 80);
}
g.rotate(400, 400, ang);
if (world) {
g.setWorldClip(350,302,100,196);
}
if (clip) {
g.setClip(350,302,100,196);
}
g.setColor(Color.red);
g.fillOval(300,300,200,200);
g.setColor(Color.blue);
g.fillRect(390,200,20,400);
g.clearClip();
g.clearWorldClip();
}
示例2: render
import org.newdawn.slick.Graphics; //導入方法依賴的package包/類
/**
* @see org.newdawn.slick.gui.AbstractComponent#render(org.newdawn.slick.gui.GUIContext,
* org.newdawn.slick.Graphics)
*/
public void render(GUIContext container, Graphics g) {
if (lastKey != -1) {
if (input.isKeyDown(lastKey)) {
if (repeatTimer < System.currentTimeMillis()) {
repeatTimer = System.currentTimeMillis() + KEY_REPEAT_INTERVAL;
keyPressed(lastKey, lastChar);
}
} else {
lastKey = -1;
}
}
Rectangle oldClip = g.getClip();
g.setWorldClip(x,y,width, height);
// Someone could have set a color for me to blend...
Color clr = g.getColor();
if (background != null) {
g.setColor(background.multiply(clr));
g.fillRect(x, y, width, height);
}
g.setColor(text.multiply(clr));
Font temp = g.getFont();
int cpos = font.getWidth(value.substring(0, cursorPos));
int tx = 0;
if (cpos > width) {
tx = width - cpos - font.getWidth("_");
}
g.translate(tx + 2, 0);
g.setFont(font);
g.drawString(value, x + 1, y + 1);
if (hasFocus() && visibleCursor) {
g.drawString("_", x + 1 + cpos + 2, y + 1);
}
g.translate(-tx - 2, 0);
if (border != null) {
g.setColor(border.multiply(clr));
g.drawRect(x, y, width, height);
}
g.setColor(clr);
g.setFont(temp);
g.clearWorldClip();
g.setClip(oldClip);
}