本文整理汇总了Java中com.badlogic.gdx.scenes.scene2d.ui.Image.setDrawable方法的典型用法代码示例。如果您正苦于以下问题:Java Image.setDrawable方法的具体用法?Java Image.setDrawable怎么用?Java Image.setDrawable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.scenes.scene2d.ui.Image
的用法示例。
在下文中一共展示了Image.setDrawable方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SlotActor
import com.badlogic.gdx.scenes.scene2d.ui.Image; //导入方法依赖的package包/类
public SlotActor(Inventory inventory, int num) {
super(new ButtonStyle());
Image image = new Image();
image.setScaling(Scaling.fit);
image.setDrawable(new SlotDrawable());
image.setTouchable(Touchable.disabled);
add(image);
setSize(getPrefWidth(), getPrefHeight());
this.inventory = inventory;
this.num = num;
InventoryManager.newSlot(this);
addListener(new SlotTooltipListener(this));
}
示例2: createInfoLabel
import com.badlogic.gdx.scenes.scene2d.ui.Image; //导入方法依赖的package包/类
private void createInfoLabel() {
infoBackground = new Image();
TextureRegionDrawable image =
new TextureRegionDrawable(AssetManager.getInstance().getTextureRegion("default"));
infoBackground.setDrawable(image.tint(new Color(0, 0, 0, 0.6f)));
infoBackground.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getWidth() / 20);
stage.addActor(infoBackground);
infoLabel = new Label("", skin);
FreeTypeFontParameter fontParameter = new FreeTypeFontParameter();
fontParameter.size = Gdx.graphics.getWidth() / 30;
LabelStyle style = new LabelStyle();
style.font = fontGenerator.generateFont(fontParameter);
style.fontColor = Color.WHITE;
infoLabel.setStyle(style);
infoLabel.setWidth(Gdx.graphics.getWidth());
stage.addActor(infoLabel);
}
示例3: dragStart
import com.badlogic.gdx.scenes.scene2d.ui.Image; //导入方法依赖的package包/类
@Override
public DragAndDrop.Payload dragStart(InputEvent event, float x, float y, int pointer) {
// if(sourceSlot.isEmpty())return payload;
TowerObject tower = (TowerObject) sourceSlot.getLast();
DragAndDrop.Payload payload = super.dragStart(event, x, y, pointer);
if (payload == null)return null;
Level.getMap().setBuild(true, tower, payload); //start drawing build grid
Image i = ((Image)payload.getValidDragActor());//nullPointer
Image inv = ((Image)payload.getDragActor());
TextureRegionDrawable t = new TextureRegionDrawable(new TextureRegion(tower.getPrototype().getTowerTexture()));
i.setDrawable(t);
inv.setDrawable(t);
dragAndDrop.setDragActorPosition(-i.getWidth()/2, i.getHeight()/2);
return payload;
}
示例4: createUI
import com.badlogic.gdx.scenes.scene2d.ui.Image; //导入方法依赖的package包/类
private void createUI() {
Image background = new Image();
background.setDrawable(new TextureRegionDrawable(AssetManager.getInstance().getTextureRegion("main_menu_background")));
background.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
background.setPosition(0, 0);
stage.addActor(background);
createPlayButton();
createAudioButton();
createLoadingLabel();
}
示例5: show
import com.badlogic.gdx.scenes.scene2d.ui.Image; //导入方法依赖的package包/类
@Override
public void show() {
batch = new SpriteBatch();
viewport = new FitViewport(Constants.DIFFICULTY_WORLD_SIZE_WIDTH, Constants.DIFFICULTY_WORLD_SIZE_HEIGHT);
renderer = new ShapeRenderer();
renderer.setAutoShapeType(true);
stage = new Stage(viewport);
Gdx.input.setInputProcessor(stage);
Skin uiSkin = new Skin(Gdx.files.internal("UiSkin/uiskin.json"));
button = new TextButton(menucontinue, uiSkin);
TextButton.TextButtonStyle textButtonStyle = new TextButton.TextButtonStyle();
textButtonStyle.font = font12;
textButtonStyle.up = uiSkin.newDrawable("white", Color.DARK_GRAY);
textButtonStyle.down = uiSkin.newDrawable("white", Color.DARK_GRAY);
textButtonStyle.checked = uiSkin.newDrawable("white", Color.DARK_GRAY);
textButtonStyle.over = uiSkin.newDrawable("white", Color.DARK_GRAY);
button.setStyle(textButtonStyle);
imageLogo = new Image();
imageLogo.setDrawable(new TextureRegionDrawable(new TextureRegion(new Texture(Gdx.files.internal("Star.png")))));
/*container=new Container<Image>(imageLogo);
container.setTransform(true); // for enabling scaling and rotation
container.size(100, 100);
container.setOrigin(Align.center);//container.getWidth() / 2, container.getHeight() / 2);
container.setPosition(100,100);
container.setScale(1); //scale according to your requirement
*/
Table table = new Table();
table.setFillParent(true);
table.add(imageLogo);
table.row();
table.add(button).width(450).height(300).pad(10);
table.row();
stage.addActor(table);
//container.addAction(Actions.parallel(/*Actions.moveTo(500, 300, 2.0f),*/Actions.rotate(1.f,1.0f)));//Actions.scaleTo(0.1f, 0.1f,2.0f)));
button.addListener(new ChangeListener() {
public void changed (ChangeEvent event, Actor actor) {
if(!victory || (victory && level == maxNumLevels))
game.ShowMenuScreen();
else
game.ShowSuperBullScreen(level +1);
}
});
}
示例6: setImage
import com.badlogic.gdx.scenes.scene2d.ui.Image; //导入方法依赖的package包/类
private void setImage(Image image, Drawable drawable) {
image.setDrawable(drawable);
image.setSize(image.getPrefWidth(), image.getPrefHeight());
}
示例7: process
import com.badlogic.gdx.scenes.scene2d.ui.Image; //导入方法依赖的package包/类
@Override
public void process(final LmlParser parser, final LmlTag tag, final Image actor, final String rawAttributeData) {
Skin skin = parser.getData().getDefaultSkin();
TiledDrawable drawable = skin.getTiledDrawable(parser.parseString(rawAttributeData, actor));
actor.setDrawable(drawable);
}