当前位置: 首页>>代码示例>>Java>>正文


Java Sprite类代码示例

本文整理汇总了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);
}
 
开发者ID:RobDangerous,项目名称:Jademula,代码行数:26,代码来源:_DirectGraphics.java

示例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);
}
 
开发者ID:queader,项目名称:Comcraft,代码行数:17,代码来源:GuiInventory.java

示例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);
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:33,代码来源:GameCanvasImplementation.java

示例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);
    }
}
 
开发者ID:aNNiMON,项目名称:JECP,代码行数:10,代码来源:PaintCanvas.java

示例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;
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:8,代码来源:GraphicsBench.java

示例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");
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:16,代码来源:DrawRegionTransMirrorRot90AnchorVCenterHCenter.java

示例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");
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:16,代码来源:DrawRegionTransRot90AnchorBottomRight.java

示例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");
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:16,代码来源:DrawRegionTransMirrorRot270AnchorBottomRight.java

示例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");
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:16,代码来源:DrawRegionTransRot90AnchorVCenterLeft.java

示例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");
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:16,代码来源:DrawRegionTransMirrorRot90AnchorVCenterRight.java

示例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");
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:16,代码来源:DrawRegionTransNoneAnchorBottomLeft.java

示例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");
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:16,代码来源:DrawRegionTransMirrorAnchorTopRight.java

示例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");
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:16,代码来源:DrawRegionTransMirrorAnchorBottomHCenter.java

示例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");
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:16,代码来源:DrawRegionTransMirrorRot180AnchorVCenterLeft.java

示例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");
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:16,代码来源:DrawRegionTransRot180AnchorVCenterHCenter.java


注:本文中的javax.microedition.lcdui.game.Sprite类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。