本文整理汇总了Java中javax.microedition.lcdui.game.Sprite类的典型用法代码示例。如果您正苦于以下问题:Java Sprite类的具体用法?Java Sprite怎么用?Java Sprite使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Sprite类属于javax.microedition.lcdui.game包,在下文中一共展示了Sprite类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawImage
import javax.microedition.lcdui.game.Sprite; //导入依赖的package包/类
public void drawImage(Image img, int x, int y, int anchor, int manipulation) {
Sprite sprite = new Sprite(img);
switch (manipulation) {
case FLIP_HORIZONTAL:
sprite.setTransform(Sprite.TRANS_MIRROR);
break;
case FLIP_VERTICAL:
//sprite.setTransform(Sprite.TRANS_MIRROR);
break;
case ROTATE_90:
sprite.setTransform(Sprite.TRANS_ROT90);
break;
case ROTATE_180:
sprite.setTransform(Sprite.TRANS_MIRROR_ROT180);
break;
case ROTATE_270:
sprite.setTransform(Sprite.TRANS_MIRROR_ROT270);
break;
}
sprite.setPosition(
x - xanchor(anchor, img.getWidth()),
y - yanchor(anchor, img.getHeight())
);
sprite.paint(g);
}
示例2: initGui
import javax.microedition.lcdui.game.Sprite; //导入依赖的package包/类
protected void initGui() {
inventoryImage = cc.textureProvider.getImage("gui/inventory_" + (Touch.isTouchSupported() ? "landscape.png" : "normal.png"));
if (Touch.isTouchSupported()) {
xInv = (cc.screenWidth - 3 - GuiButtonMoveControl.getButtonWidth() - 3) / 2 - inventoryImage.getWidth() / 2;
yInv = (cc.screenHeight) / 2 - inventoryImage.getHeight() / 2;
elementsList.addElement(new GuiButtonPictured(cc, this, 0, cc.screenWidth - GuiButtonPictured.getButtonWidth() - 3, cc.screenHeight - GuiButtonPictured.getButtonHeight() - 3, "gui/button_exit.png", Sprite.TRANS_ROT90));
elementsList.addElement(new GuiButtonPictured(cc, this, 1, cc.screenWidth - GuiButtonPictured.getButtonWidth() - 3, 3, "gui/button_quick_menu.png", Sprite.TRANS_ROT90));
} else {
xInv = (cc.screenWidth) / 2 - inventoryImage.getWidth() / 2;
yInv = (cc.screenHeight - 3 - GuiButtonMoveControl.getButtonHeight() - 3) / 2 - inventoryImage.getHeight() / 2 + 3 + GuiButtonMoveControl.getButtonHeight() + 3;
}
guiContainer = new GuiContainerInventory(cc, this, xInv + 5, yInv + 5);
}
示例3: drawImageRotated
import javax.microedition.lcdui.game.Sprite; //导入依赖的package包/类
/**
* @inheritDoc
*/
public void drawImageRotated(Object graphics, Object img, int x, int y, int degrees) {
javax.microedition.lcdui.Image i = (javax.microedition.lcdui.Image) img;
int t;
switch (degrees % 360) {
case 0:
drawImage(graphics, img, x, y);
return;
case 90:
t = Sprite.TRANS_ROT90;
break;
case 180:
t = Sprite.TRANS_ROT180;
break;
case 270:
t = Sprite.TRANS_ROT270;
break;
default:
throw new IllegalArgumentException("Unsupported value for drawImageRotated: " + degrees);
}
javax.microedition.lcdui.Graphics nativeGraphics = (javax.microedition.lcdui.Graphics) graphics;
nativeGraphics.drawRegion(i, 0, 0, i.getWidth(),
i.getHeight(), t, x, y,
javax.microedition.lcdui.Graphics.TOP | javax.microedition.lcdui.Graphics.LEFT);
}
示例4: paint
import javax.microedition.lcdui.game.Sprite; //导入依赖的package包/类
protected void paint(Graphics g) {
listener.onPaint(graphics);
if (isLandscape) {
g.drawRegion(image, 0, 0, width, height, Sprite.TRANS_ROT90,
0, 0, Graphics.TOP | Graphics.LEFT);
} else {
g.drawImage(image, 0, 0, Graphics.TOP | Graphics.LEFT);
}
}
示例5: executeFrame
import javax.microedition.lcdui.game.Sprite; //导入依赖的package包/类
public void executeFrame(Graphics g, long numOps) {
for (long j = 0; j < numOps; j++) {
g.drawRegion(srcImages[curImageIndex], 0, 0, width, height, Sprite.TRANS_NONE, width / 2, height / 2, Graphics.VCENTER|Graphics.HCENTER);
curImageIndex = (curImageIndex + 1) % srcImages.length;
}
curImageIndex = (curImageIndex + 1) % srcImages.length;
}
示例6: paint
import javax.microedition.lcdui.game.Sprite; //导入依赖的package包/类
protected void paint(Graphics screenG) {
Image image;
try {
image = Image.createImage("/gfx/images/colorRects.png");
} catch (java.io.IOException e) {
System.out.println("FAIL - " + e);
return;
}
screenG.setColor(255, 255, 255);
screenG.fillRect(0, 0, getWidth(), getHeight());
screenG.drawRegion(image, 10, 15, 70, 95, Sprite.TRANS_MIRROR_ROT90, getWidth() / 2, getHeight() / 2, Graphics.VCENTER | Graphics.HCENTER);
System.out.println("PAINTED");
}
示例7: paint
import javax.microedition.lcdui.game.Sprite; //导入依赖的package包/类
protected void paint(Graphics screenG) {
Image image;
try {
image = Image.createImage("/gfx/images/colorRects.png");
} catch (java.io.IOException e) {
System.out.println("FAIL - " + e);
return;
}
screenG.setColor(255, 255, 255);
screenG.fillRect(0, 0, getWidth(), getHeight());
screenG.drawRegion(image, 10, 15, 70, 95, Sprite.TRANS_ROT90, getWidth() / 2, getHeight() / 2, Graphics.BOTTOM | Graphics.RIGHT);
System.out.println("PAINTED");
}
示例8: paint
import javax.microedition.lcdui.game.Sprite; //导入依赖的package包/类
protected void paint(Graphics screenG) {
Image image;
try {
image = Image.createImage("/gfx/images/colorRects.png");
} catch (java.io.IOException e) {
System.out.println("FAIL - " + e);
return;
}
screenG.setColor(255, 255, 255);
screenG.fillRect(0, 0, getWidth(), getHeight());
screenG.drawRegion(image, 10, 15, 70, 95, Sprite.TRANS_MIRROR_ROT270, getWidth() / 2, getHeight() / 2, Graphics.BOTTOM | Graphics.RIGHT);
System.out.println("PAINTED");
}
示例9: paint
import javax.microedition.lcdui.game.Sprite; //导入依赖的package包/类
protected void paint(Graphics screenG) {
Image image;
try {
image = Image.createImage("/gfx/images/colorRects.png");
} catch (java.io.IOException e) {
System.out.println("FAIL - " + e);
return;
}
screenG.setColor(255, 255, 255);
screenG.fillRect(0, 0, getWidth(), getHeight());
screenG.drawRegion(image, 10, 15, 70, 95, Sprite.TRANS_ROT90, getWidth() / 2, getHeight() / 2, Graphics.VCENTER | Graphics.LEFT);
System.out.println("PAINTED");
}
示例10: paint
import javax.microedition.lcdui.game.Sprite; //导入依赖的package包/类
protected void paint(Graphics screenG) {
Image image;
try {
image = Image.createImage("/gfx/images/colorRects.png");
} catch (java.io.IOException e) {
System.out.println("FAIL - " + e);
return;
}
screenG.setColor(255, 255, 255);
screenG.fillRect(0, 0, getWidth(), getHeight());
screenG.drawRegion(image, 10, 15, 70, 95, Sprite.TRANS_MIRROR_ROT90, getWidth() / 2, getHeight() / 2, Graphics.VCENTER | Graphics.RIGHT);
System.out.println("PAINTED");
}
示例11: paint
import javax.microedition.lcdui.game.Sprite; //导入依赖的package包/类
protected void paint(Graphics screenG) {
Image image;
try {
image = Image.createImage("/gfx/images/colorRects.png");
} catch (java.io.IOException e) {
System.out.println("FAIL - " + e);
return;
}
screenG.setColor(255, 255, 255);
screenG.fillRect(0, 0, getWidth(), getHeight());
screenG.drawRegion(image, 10, 15, 70, 95, Sprite.TRANS_NONE, getWidth() / 2, getHeight() / 2, Graphics.BOTTOM | Graphics.LEFT);
System.out.println("PAINTED");
}
示例12: paint
import javax.microedition.lcdui.game.Sprite; //导入依赖的package包/类
protected void paint(Graphics screenG) {
Image image;
try {
image = Image.createImage("/gfx/images/colorRects.png");
} catch (java.io.IOException e) {
System.out.println("FAIL - " + e);
return;
}
screenG.setColor(255, 255, 255);
screenG.fillRect(0, 0, getWidth(), getHeight());
screenG.drawRegion(image, 10, 15, 70, 95, Sprite.TRANS_MIRROR, getWidth() / 2, getHeight() / 2, Graphics.TOP | Graphics.RIGHT);
System.out.println("PAINTED");
}
示例13: paint
import javax.microedition.lcdui.game.Sprite; //导入依赖的package包/类
protected void paint(Graphics screenG) {
Image image;
try {
image = Image.createImage("/gfx/images/colorRects.png");
} catch (java.io.IOException e) {
System.out.println("FAIL - " + e);
return;
}
screenG.setColor(255, 255, 255);
screenG.fillRect(0, 0, getWidth(), getHeight());
screenG.drawRegion(image, 10, 15, 70, 95, Sprite.TRANS_MIRROR, getWidth() / 2, getHeight() / 2, Graphics.BOTTOM | Graphics.HCENTER);
System.out.println("PAINTED");
}
示例14: paint
import javax.microedition.lcdui.game.Sprite; //导入依赖的package包/类
protected void paint(Graphics screenG) {
Image image;
try {
image = Image.createImage("/gfx/images/colorRects.png");
} catch (java.io.IOException e) {
System.out.println("FAIL - " + e);
return;
}
screenG.setColor(255, 255, 255);
screenG.fillRect(0, 0, getWidth(), getHeight());
screenG.drawRegion(image, 10, 15, 70, 95, Sprite.TRANS_MIRROR_ROT180, getWidth() / 2, getHeight() / 2, Graphics.VCENTER | Graphics.LEFT);
System.out.println("PAINTED");
}
示例15: paint
import javax.microedition.lcdui.game.Sprite; //导入依赖的package包/类
protected void paint(Graphics screenG) {
Image image;
try {
image = Image.createImage("/gfx/images/colorRects.png");
} catch (java.io.IOException e) {
System.out.println("FAIL - " + e);
return;
}
screenG.setColor(255, 255, 255);
screenG.fillRect(0, 0, getWidth(), getHeight());
screenG.drawRegion(image, 10, 15, 70, 95, Sprite.TRANS_ROT180, getWidth() / 2, getHeight() / 2, Graphics.VCENTER | Graphics.HCENTER);
System.out.println("PAINTED");
}