本文整理匯總了Java中com.badlogic.gdx.scenes.scene2d.ui.Image.setOrigin方法的典型用法代碼示例。如果您正苦於以下問題:Java Image.setOrigin方法的具體用法?Java Image.setOrigin怎麽用?Java Image.setOrigin使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.badlogic.gdx.scenes.scene2d.ui.Image
的用法示例。
在下文中一共展示了Image.setOrigin方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setUpSkinImages
import com.badlogic.gdx.scenes.scene2d.ui.Image; //導入方法依賴的package包/類
public void setUpSkinImages() {
skinImage = new Image(skins.get(position).getTextureRegion());
skinImageRotation = new Image(skins.get(position).getTextureRegion());
skinImage.setSize(3f, 3f);
skinImage.setOrigin(skinImage.getWidth() / 2, skinImage.getHeight() / 2);
skinImage.setPosition(Constants.WIDTH / 3 - skinImage.getWidth() / 2, Constants.HEIGHT / 2);
skinImageRotation.setSize(3f, 3f);
skinImageRotation.setOrigin(skinImageRotation.getWidth() / 2, skinImageRotation.getHeight() / 2);
skinImageRotation.setPosition(Constants.WIDTH * 2 / 3 - skinImageRotation.getWidth() / 2, Constants.HEIGHT / 2);
SequenceAction rotateAction = new SequenceAction();
rotateAction.addAction(Actions.rotateBy(360, 0.5f, Interpolation.linear));
RepeatAction infiniteLoop = new RepeatAction();
infiniteLoop.setCount(RepeatAction.FOREVER);
infiniteLoop.setAction(rotateAction);
skinImageRotation.addAction(infiniteLoop);
stage.addActor(skinImageRotation);
stage.addActor(skinImage);
}
示例2: setUpMoneyLabel
import com.badlogic.gdx.scenes.scene2d.ui.Image; //導入方法依賴的package包/類
public void setUpMoneyLabel() {
moneyImage = new Image(AssetsManager.getTextureRegion(Constants.COIN_NAME));
moneyImage.setSize(2.5f, 2.5f);
moneyImage.setPosition(Constants.WIDTH * 2 / 3 + 0.5f, onFinish.getY() + onFinish.getHeight() * 1.3f + moneyImage.getHeight() / 5.5f);
moneyImage.setOrigin(moneyImage.getWidth() / 2, moneyImage.getHeight() / 2);
moneyImage.setVisible(false);
stage.addActor(moneyImage);
Label.LabelStyle labelStyle = new Label.LabelStyle();
labelStyle.font = AssetsManager.getMediumFont();
moneyLabel = new Label(" " + 0, labelStyle);
moneyLabel.setFontScale(0.065f);
moneyLabel.setSize(moneyLabel.getWidth() * moneyLabel.getFontScaleX(), moneyLabel.getHeight() * moneyLabel.getFontScaleY());
moneyLabel.setPosition(moneyImage.getX() - moneyLabel.getWidth(), moneyImage.getY());
moneyLabel.setVisible(false);
stage.addActor(moneyLabel);
}
示例3: createKnightPosition
import com.badlogic.gdx.scenes.scene2d.ui.Image; //導入方法依賴的package包/類
/**
* Create an image used to highlight valid positions for a knight.
*
* @param localPlayer the local player, always
*/
public Image createKnightPosition(Player localPlayer) {
Image knightPos = new Image(knightBg);
// The highlighted position should be a bit transparent
float alpha = 0.75f;
// It should also take the color of the local player
switch (localPlayer.getColor()) {
case WHITE:
knightPos.setColor(Color.WHITE.r, Color.WHITE.g, Color.WHITE.b, alpha);
break;
case BLUE:
knightPos.setColor(Color.BLUE.r, Color.BLUE.g, Color.BLUE.b, alpha);
break;
case RED:
knightPos.setColor(Color.RED.r, Color.RED.g, Color.RED.b, alpha);
break;
case ORANGE:
knightPos.setColor(Color.ORANGE.r, Color.ORANGE.g, Color.ORANGE.b, alpha);
break;
case YELLOW:
knightPos.setColor(Color.YELLOW.r, Color.YELLOW.g, Color.YELLOW.b, alpha);
break;
}
// Scale down the image
final float knightScale = 1 / 8f;
knightPos.setSize(knightScale * knightPos.getWidth(), knightScale * knightPos.getHeight());
// Place the origin in the center of the image to make it easier to draw
knightPos.setOrigin(knightPos.getWidth() / 2f, knightPos.getHeight() / 2f);
return knightPos;
}
示例4: createCityWall
import com.badlogic.gdx.scenes.scene2d.ui.Image; //導入方法依賴的package包/類
/** Create a city wall image with the provided color */
Image createCityWall(PlayerColor color) {
// Create the image from the texture region
Image cityWallImage = new Image(cityWall);
// Set the color
switch (color) {
case WHITE:
cityWallImage.setColor(Color.WHITE);
break;
case BLUE:
cityWallImage.setColor(Color.BLUE);
break;
case RED:
cityWallImage.setColor(Color.RED);
break;
case ORANGE:
cityWallImage.setColor(Color.ORANGE);
break;
case YELLOW:
cityWallImage.setColor(Color.YELLOW);
break;
}
// Scale down the image
final float imageScale = 1 / 4f;
cityWallImage.setSize(imageScale * cityWallImage.getWidth(), imageScale * cityWallImage.getHeight());
// Place the origin in the center of the image to make it easier to draw
cityWallImage.setOrigin(cityWallImage.getWidth() / 2f, cityWallImage.getHeight() / 2f);
return cityWallImage;
}
示例5: setUpOnPause
import com.badlogic.gdx.scenes.scene2d.ui.Image; //導入方法依賴的package包/類
/**
* SETTING ONSTATE IMAGES
*/
public void setUpOnPause() {
onPause = new Image(AssetsManager.getTextureRegion(Constants.PAUSE_IMAGE_NAME));
onPause.setVisible(false);
onPause.setSize(Constants.WIDTH, Constants.ONPAUSE_HEIGHT);
onPause.setPosition(Constants.WIDTH / 2 - onPause.getWidth() / 2, Constants.HEIGHT / 2 - onPause.getHeight() / 2);
onPause.setOrigin(onPause.getWidth() / 2, onPause.getHeight() / 2);
onPause.addAction(setOnStateImageAction(1.2f));
stage.addActor(onPause);
}
示例6: setUpOnFinish
import com.badlogic.gdx.scenes.scene2d.ui.Image; //導入方法依賴的package包/類
public void setUpOnFinish() {
onFinish = new Image(AssetsManager.getTextureRegion(Constants.FINISH_IMAGE_NAME));
onFinish.setVisible(false);
onFinish.setSize(Constants.WIDTH - 5, Constants.ONFINISH_HEIGHT);
onFinish.setPosition(Constants.WIDTH / 2 - onFinish.getWidth() / 2, Constants.HEIGHT / 2 - onFinish.getHeight() / 5);
onFinish.setOrigin(onFinish.getWidth() / 2, onFinish.getHeight() / 2);
onFinish.addAction(setOnStateImageAction(1.2f));
stage.addActor(onFinish);
}
示例7: setUpOnResume
import com.badlogic.gdx.scenes.scene2d.ui.Image; //導入方法依賴的package包/類
public void setUpOnResume() {
onResume = new Image(AssetsManager.getTextureRegion(Constants.RESUME_IMAGE_NAME));
onResume.setAlign(Align.center);
onResume.setSize(Constants.ONRESUME_WIDTH, Constants.ONRESUME_HEIGHT);
onResume.setOrigin(onResume.getWidth() / 2, onResume.getHeight() / 2);
onResume.setPosition(Constants.WIDTH / 2 - onResume.getWidth() / 2, Constants.HEIGHT / 2 - onResume.getHeight() * 1.5f);
onResume.addAction(setOnStateImageAction(0.7f));
stage.addActor(onResume);
}
示例8: RotateODImagesSubView
import com.badlogic.gdx.scenes.scene2d.ui.Image; //導入方法依賴的package包/類
public RotateODImagesSubView(String imageBaseName, int dx, int dy, float frameDuration, int initialIndex) {
this.frameDuration = frameDuration;
currentIndex = initialIndex;
//dx == 1 && dy == 1 -> top right
orto = new Image(Config.skin, imageBaseName + "-ortogonal");
dia = new Image(Config.skin, imageBaseName + "-diagonal");
orto.setOrigin(orto.getWidth() / 2f, orto.getHeight() / 2f);
dia.setOrigin(dia.getWidth() / 2f, dia.getHeight() / 2f);
updateImage();
targetIndex = calcTargetIndex(dx, dy);
}
示例9: visualize
import com.badlogic.gdx.scenes.scene2d.ui.Image; //導入方法依賴的package包/類
@Override public IFuture<Void> visualize(final T result) {
final Future<Void> future = Future.make();
final WorldObjectView actorView = visualizer.viewController.getView(result.getActor());
WorldObjectView targetView = visualizer.viewController.getView(result.getTarget());
visualizer.viewController.world.dispatcher.dispatch(ResultVisualizer.VISUALIZE_ATTACK, result.getActor());
Vector2 direction = tmp
.set(result.getTarget().getX(), result.getTarget().getY())
.sub(result.getActor().getX(), result.getActor().getY());
float dx = targetView.getX() - actorView.getX();
float dy = targetView.getY() - actorView.getY();
visualizer.viewController.scroller.centerOn(result.getTarget());
final Image arrow = new Image(Config.skin,"animation/" + result.getAbility().name + "-shot");
arrow.setPosition(actorView.getX(), actorView.getY());
visualizer.viewController.effectLayer.addActor(arrow);
arrow.setOrigin(13, 14);
arrow.setRotation(direction.angle() - 45);
arrow.addAction(Actions.sequence(
Actions.moveBy(dx, dy, tmp.set(dx, dy).len() * 0.002f),
Actions.run(new Runnable() {
@Override public void run() {
SoundManager.instance.playSoundIfExists(result.getAbility().soundName);
arrow.remove();
future.happen();
}
})
));
return future;
}
示例10: visualize
import com.badlogic.gdx.scenes.scene2d.ui.Image; //導入方法依賴的package包/類
@Override public IFuture<Void> visualize(ITargetOwner result) {
final Future<Void> future = new Future<Void>();
SoundManager.instance.playSoundIfExists(soundName);
Image image = new Image(Config.skin, "effect-luck-image");
image.setColor(color);
image.setScale(0, 0);
image.setOrigin(image.getWidth() / 2, image.getHeight() / 2);
image.setPosition(
result.getTarget().getX() * ViewController.CELL_SIZE + (ViewController.CELL_SIZE - image.getWidth()) * 0.5f,
result.getTarget().getY() * ViewController.CELL_SIZE + (ViewController.CELL_SIZE - image.getHeight()) * 0.5f + 6
);
visualizer.viewController.effectLayer.addActor(image);
image.addAction(
Actions.sequence(
Actions.parallel(
Actions.scaleTo(0.75f, 0.75f, 0.5f, Interpolation.sine),
Actions.rotateBy(135, 0.5f)
),
Actions.parallel(
Actions.scaleTo(0, 0, 0.5f, Interpolation.sine),
Actions.rotateBy(135, 0.5f)
),
Actions.run(future),
Actions.removeActor()
)
);
return future;
}
示例11: doShow
import com.badlogic.gdx.scenes.scene2d.ui.Image; //導入方法依賴的package包/類
@Override protected void doShow(Params params) {
label.setKey(params.locKey);
imageTable.clearChildren();
Image left = new Image(Config.skin, "ui-tutorial-window-halfline");
left.setOrigin(left.getWidth() / 2f, left.getHeight() / 2f);
left.rotateBy(180);
imageTable.add(left);
imageTable.add(ViewController.createView(new Creature(params.die, PlayerHelper.defaultProtagonist))).padLeft(2).padRight(2);
imageTable.add(new Image(Config.skin, "ui-tutorial-window-halfline"));
}
示例12: LoadingIndicator
import com.badlogic.gdx.scenes.scene2d.ui.Image; //導入方法依賴的package包/類
public LoadingIndicator(LoadingIndicatorStyle style) {
if (style.spinnerImage != null) {
Image spinner = new Image(style.spinnerImage);
spinner.setOrigin(spinner.getWidth() / 2, spinner.getHeight() / 2);
spinner.addAction(Actions.forever(Actions.rotateBy(-360, style.rotationDuration)));
add(spinner).center();
row();
}
loadingWhatLabel = new Label(Strings.getString(UIManager.STRING_TABLE, "loading", ""), style.loadingLabelStyle);
add(loadingWhatLabel)
.center().padTop(style.loadingLabelMarginTop);
pack();
}
示例13: LoadingWindow
import com.badlogic.gdx.scenes.scene2d.ui.Image; //導入方法依賴的package包/類
public LoadingWindow(T windowToLoad, LoadingIndicatorStyle style,
Loader<T> loader) {
super(windowToLoad.getTitleLabel().getText().toString(), windowToLoad
.getStyle());
setMovable(false);
this.windowToLoad = windowToLoad;
this.loader = loader;
loader.load(am);
Group parent = windowToLoad.getParent();
windowToLoad.remove();
windowToLoad.setVisible(false);
parent.addActor(this);
setVisible(true);
Image spinner = new Image(style.spinnerImage);
spinner.setOrigin(spinner.getWidth() / 2, spinner.getHeight() / 2);
spinner.getColor().a = 0;
spinner.addAction(Actions.fadeIn(0.8f));
spinner.addAction(Actions.forever(Actions.rotateBy(-360, style.rotationDuration)));
add(spinner).center();
row();
add(new Label(Strings.getString(UIManager.STRING_TABLE, "loading",""), style.loadingLabelStyle))
.center().padTop(style.loadingLabelMarginTop);
pack();
float minWidth = getWidth();
float minHeight = getHeight();
setWidth(windowToLoad.getWidth() > minWidth ? windowToLoad.getWidth() : minWidth);
setHeight(windowToLoad.getHeight() > minHeight ? windowToLoad.getHeight() : minHeight);
setPosition(windowToLoad.getX(), windowToLoad.getY());
}
示例14: createBodyAt
import com.badlogic.gdx.scenes.scene2d.ui.Image; //導入方法依賴的package包/類
public Body createBodyAt(Vector2 pt, AtlasRegion frame)
{
// Get the sprite from the sprite sheet
candy = new Image(frame);
candy.setOrigin(candy.getWidth()/2, candy.getHeight()/2);
this.addActor(candy);
// Defines the body of your candy
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyType.DynamicBody;
bodyDef.position.set(new Vector2(pt.x/PTM_RATIO, pt.y/PTM_RATIO));
bodyDef.linearDamping = 0.3f;
Body body = world.createBody(bodyDef);
body.setUserData(candy);
// Define the fixture as a polygon
FixtureDef fixtureDef = new FixtureDef();
PolygonShape spriteShape = new PolygonShape();
Vector2[] verts = {
new Vector2((-candy.getWidth()/2) / PTM_RATIO,
(-candy.getHeight()/2) / PTM_RATIO),
new Vector2((candy.getWidth()/2) / PTM_RATIO,
(-candy.getHeight()/2) / PTM_RATIO),
new Vector2((candy.getWidth()/2) / PTM_RATIO,
(candy.getHeight()/2) / PTM_RATIO),
new Vector2((-candy.getWidth()/2) / PTM_RATIO,
(candy.getHeight()/2) / PTM_RATIO),
};
spriteShape.set(verts);
fixtureDef.shape = spriteShape;
fixtureDef.density = 30.0f;
fixtureDef.friction = 0.2f;
fixtureDef.restitution = 0.9f;
fixtureDef.filter.categoryBits = 0x01;
fixtureDef.filter.maskBits = 0x01;
body.createFixture(fixtureDef);
bodies.add(body);
return body;
}