本文整理汇总了Java中javax.microedition.lcdui.game.Sprite.TRANS_ROT180属性的典型用法代码示例。如果您正苦于以下问题:Java Sprite.TRANS_ROT180属性的具体用法?Java Sprite.TRANS_ROT180怎么用?Java Sprite.TRANS_ROT180使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.microedition.lcdui.game.Sprite
的用法示例。
在下文中一共展示了Sprite.TRANS_ROT180属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例2: 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);
}
}
}
示例3: 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;
}
示例4: 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));
}