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


Java Image.setOrigin方法代码示例

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

示例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);
}
 
开发者ID:ZephyrVentum,项目名称:FlappySpinner,代码行数:18,代码来源:GameScreen.java

示例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;
}
 
开发者ID:teobaranga,项目名称:Catan,代码行数:40,代码来源:GamePieces.java

示例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;
}
 
开发者ID:teobaranga,项目名称:Catan,代码行数:34,代码来源:GamePieces.java

示例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);
}
 
开发者ID:ZephyrVentum,项目名称:FlappySpinner,代码行数:13,代码来源:GameScreen.java

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

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

示例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);
}
 
开发者ID:ratrecommends,项目名称:dice-heroes,代码行数:12,代码来源:RotateODImagesSubView.java

示例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;
}
 
开发者ID:ratrecommends,项目名称:dice-heroes,代码行数:31,代码来源:CommonShotVisualizer.java

示例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;
}
 
开发者ID:ratrecommends,项目名称:dice-heroes,代码行数:29,代码来源:BeamVisualizer.java

示例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"));
}
 
开发者ID:ratrecommends,项目名称:dice-heroes,代码行数:11,代码来源:DieMessageWindow.java

示例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();
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:14,代码来源:LoadingIndicator.java

示例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());
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:31,代码来源:LoadingWindow.java

示例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;
}
 
开发者ID:game-libgdx-unity,项目名称:GDX-Engine,代码行数:47,代码来源:Rope.java


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