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


Java Sprite.TRANS_ROT90属性代码示例

本文整理汇总了Java中javax.microedition.lcdui.game.Sprite.TRANS_ROT90属性的典型用法代码示例。如果您正苦于以下问题:Java Sprite.TRANS_ROT90属性的具体用法?Java Sprite.TRANS_ROT90怎么用?Java Sprite.TRANS_ROT90使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在javax.microedition.lcdui.game.Sprite的用法示例。


在下文中一共展示了Sprite.TRANS_ROT90属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: drawImageRotated

/**
 * @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,代码行数:32,代码来源:GameCanvasImplementation.java

示例2: initIngameGui

public void initIngameGui() {
    initLoadingChunksImage();

    if (Touch.isTouchSupported()) {
        String imageName = "gui/arrow_key.png";

        //LEFT/BACK/RIGHT/FORW
        elementsList.addElement(new GuiButtonMoveControl(cc, this, 0, 0, 0, imageName, Sprite.TRANS_NONE));
        elementsList.addElement(new GuiButtonMoveControl(cc, this, 1, 0, 0 + GuiButtonMoveControl.getButtonHeight(), imageName, Sprite.TRANS_MIRROR_ROT270));
        elementsList.addElement(new GuiButtonMoveControl(cc, this, 2, 0, 0 + GuiButtonMoveControl.getButtonHeight() * 2, imageName, Sprite.TRANS_MIRROR_ROT180));
        elementsList.addElement(new GuiButtonMoveControl(cc, this, 3, 0 + GuiButtonMoveControl.getButtonWidth(), 0 + GuiButtonMoveControl.getButtonHeight(), imageName, Sprite.TRANS_ROT90));
        //DOWN/UP
        elementsList.addElement(new GuiButtonMoveControl(cc, this, 4, 0, cc.screenHeight - GuiButtonMoveControl.getButtonHeight(), imageName, Sprite.TRANS_MIRROR_ROT270));
        elementsList.addElement(new GuiButtonMoveControl(cc, this, 5, 0 + GuiButtonMoveControl.getButtonWidth(), cc.screenHeight - GuiButtonMoveControl.getButtonHeight(), imageName, Sprite.TRANS_ROT90));
        //Fast slot bar
        int startY = (cc.screenHeight - 4 * GuiButtonMoveControl.getButtonHeight()) / 2;

        for (int i = 0; i < 4; ++i) {
            elementsList.addElement(new GuiButtonArea(this, 6 + i, cc.screenWidth - 3 - 50, startY + i * 50, 50, 50));
        }

        screenshotButton = new GuiButtonPictured(cc, this, 10, (int) ((cc.screenWidth - GuiButtonPictured.getButtonWidth()) * 3f / 5), cc.screenHeight - GuiButtonPictured.getButtonHeight(), "gui/button_screenshot.png", Sprite.TRANS_ROT90);
        elementsList.addElement(screenshotButton);

        screenshotButton.drawButton = cc.settings.screenshotMode;
    }
}
 
开发者ID:queader,项目名称:Comcraft,代码行数:27,代码来源:GuiIngame.java

示例3: loadImageLandscape

private void loadImageLandscape(String path) {
    Image image = null;

    int transform = Touch.isTouchSupported() ? Sprite.TRANS_ROT90 : Sprite.TRANS_NONE;

    try {
        Image tempImage = Image.createImage(cc.texturePackList.getResourceAsStream(path));

        image = Image.createImage(tempImage, 0, 0, tempImage.getWidth(), tempImage.getHeight(), transform);
    } catch (IOException ex) {
        throw new ComcraftException("Can't load texture from texturepack: " + path, ex);
    }

    loadedImagesList.put(path, image);
}
 
开发者ID:queader,项目名称:Comcraft,代码行数:15,代码来源:TextureManager.java

示例4: initEffect

private void initEffect(String path) {
    appearance = new Appearance();

    Image image = cc.textureProvider.getImage(path);

    int width = image.getWidth() / 4;
    int height = image.getHeight() / 4;

    for (int yI = 0; yI < 4; ++yI) {
        for (int xI = 0; xI < 4; ++xI) {
            int trans = rand.nextInt(5);

            if (trans == 0) {
                trans = Sprite.TRANS_NONE;
            } else if (trans == 1) {
                trans = Sprite.TRANS_ROT180;
            } else if (trans == 2) {
                trans = Sprite.TRANS_ROT90;
            } else if (trans == 3) {
                trans = Sprite.TRANS_ROT270;
            } else {
                trans = Sprite.TRANS_MIRROR;
            }

            Image frame = Image.createImage(image, xI * width, yI * height, width, height, trans);

            Image2D image2D = new Image2D(Image2D.RGBA, frame);

            explosionSprites3D[yI * 4 + xI] = new Sprite3D(true, image2D, appearance);
        }
    }
}
 
开发者ID:queader,项目名称:Comcraft,代码行数:32,代码来源:EffectExplosion.java

示例5: createImage

/**
 * Creates a new image based upon the transformed region of another image
 * @param image Source image
 * @param x x co-ordinate of the source region
 * @param y y co-ordinate of the source region
 * @param w width of the source region
 * @param h height of the source region
 * @param transform Transform to be applied
 * @return New image
 * @see Graphics#drawRegion(javax.microedition.lcdui.Image, int, int, int, int, int, int, int, int)
 * #see game.Sprite
 */
public static Image createImage(Image image, int x, int y, int w, int h, int transform)
{
    int ow = w;
    int oh = h;
    // Work out what shape the new image will be...
    switch (transform)
    {
        case Sprite.TRANS_MIRROR:
        case Sprite.TRANS_MIRROR_ROT180:
        case Sprite.TRANS_ROT180:
        case Sprite.TRANS_NONE:
            break;
        case Sprite.TRANS_MIRROR_ROT270:
        case Sprite.TRANS_MIRROR_ROT90:
        case Sprite.TRANS_ROT270:
        case Sprite.TRANS_ROT90:
            ow = h;
            oh = w;
            break;
    }
    // Create empty new image
    Image newImage = createImage(ow, oh);
    Graphics g = newImage.getGraphics();
    g.drawRegion(image, x, y, w, h, transform, 0, 0, 0);
    return newImage;
}
 
开发者ID:SnakeSVx,项目名称:ev3,代码行数:38,代码来源:Image.java

示例6: createImage

public Image createImage(Image image, int x, int y, int width, int height, int transform) {
	// TODO AndroidDisplayGraphics.drawRegion code is similar
	if (image == null)
		throw new NullPointerException();
	if (x + width > image.getWidth() || y + height > image.getHeight() || width <= 0 || height <= 0 || x < 0
			|| y < 0)
		throw new IllegalArgumentException("Area out of Image");

       Bitmap img;
       if (image.isMutable()) {
           img = ((AndroidMutableImage) image).getBitmap();
       } else {
           img = ((AndroidImmutableImage) image).getBitmap();
       }            

       Matrix matrix = new Matrix();
       switch (transform) {
       case Sprite.TRANS_NONE: {
           break;
       }
       case Sprite.TRANS_ROT90: {
       	matrix.preRotate(90);
           break;
       }
       case Sprite.TRANS_ROT180: {
           matrix.preRotate(180);
           break;
       }
       case Sprite.TRANS_ROT270: {
           matrix.preRotate(270);
           break;
       }
       case Sprite.TRANS_MIRROR: {
       	matrix.preScale(-1, 1);
           break;
       }
       case Sprite.TRANS_MIRROR_ROT90: {
       	matrix.preScale(-1, 1);
       	matrix.preRotate(-90);
           break;
       }
       case Sprite.TRANS_MIRROR_ROT180: {
       	matrix.preScale(-1, 1);
           matrix.preRotate(-180);
           break;
       }
       case Sprite.TRANS_MIRROR_ROT270: {
       	matrix.preScale(-1, 1);
           matrix.preRotate(-270);
           break;
       }
       default:
           throw new IllegalArgumentException("Bad transform");
       }

	return new AndroidImmutableImage(Bitmap.createBitmap(img, x, y, width, height, matrix, true));
}
 
开发者ID:Helltar,项目名称:AMPASIDE,代码行数:57,代码来源:AndroidDeviceDisplay.java


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