本文整理汇总了Java中com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable类的典型用法代码示例。如果您正苦于以下问题:Java TextureRegionDrawable类的具体用法?Java TextureRegionDrawable怎么用?Java TextureRegionDrawable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TextureRegionDrawable类属于com.badlogic.gdx.scenes.scene2d.utils包,在下文中一共展示了TextureRegionDrawable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Arrow
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; //导入依赖的package包/类
public Arrow(String name, int health, AnimationLoader anims, float posX, float posY, Entity tg){
super(name, health,anims);
scale = 0.5f;
target = tg;
tpos = target.getPosition();
texl = anims.getTex("arrowleft");
texr = anims.getTex("arrowright");
currentframe = new TextureRegion(texl);
currentframe.flip(false, true);
enemyDrawable = new TextureRegionDrawable(currentframe);
// Create enemy Image/Actor
enemy = new Image(enemyDrawable);
enemy.setX(posX);
enemy.setY(posY);
scale = ((Gdx.graphics.getHeight() - getPosition().y) / 1000) * 0.5f;
enemy.setScale(scale);
}
示例2: makeDroidTowersLogo
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; //导入依赖的package包/类
private void makeDroidTowersLogo(boolean animateBuildOut) {
TextureAtlas.AtlasRegion droidTowersLogoTexture = atlas2.findRegion("droid-towers-logo");
droidTowersLogo = new Image(new TextureRegionDrawable(droidTowersLogoTexture), fit);
droidTowersLogo.setWidth(Math.min(getStage().getWidth() * 0.5f, droidTowersLogo.getWidth()));
droidTowersLogo.layout();
droidTowersLogo.setY(getStage().getHeight() - droidTowersLogo.getImageHeight() - 75);
droidTowersLogo.setX(50);
if (animateBuildOut) {
droidTowersLogo.setX(-droidTowersLogo.getImageWidth());
Tween.to(droidTowersLogo, WidgetAccessor.POSITION, CAMERA_PAN_DOWN_DURATION).delay(50).target(50, droidTowersLogo.getY())
.ease(TweenEquations.easeInOutExpo).start(TweenSystem.manager());
}
container.addActor(droidTowersLogo);
}
示例3: createSkins
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; //导入依赖的package包/类
/**
* Function used to create the Skins' Buttons and Labels and associate them to a given table, organized.
* It also adds Listeners to the Skins' Buttons.
*
* @param table Table where the Skins' Labels and Buttons will be organized.
*/
private void createSkins(Table table) {
for (int i = 0; i < game.getNumSkins(); ++i) {
//Adding Buttons and Labels to the Arrays
skinButtons.add(new Button(new TextureRegionDrawable(new TextureRegion(game.getAssetManager().get("big_skins/skin" + (i < 10 ? "0" : "") + i + ".png", Texture.class)))));
skinLabels.add(new Label("Current", skin1));
final int j = i; //Needed for Listener initialization
skinButtons.get(i).addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
setCurrentLabel(j);
}
});
table.add(skinButtons.get(i)).size(BUTTON_SIZE, BUTTON_SIZE).pad(IMAGE_EDGE);
}
table.row();
for (int i = 0; i < game.getNumSkins(); ++i)
table.add(skinLabels.get(i));
initializeCurrentSkin();
}
示例4: initHUD
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; //导入依赖的package包/类
/**
* Function used to initialize all the elements of the HUD and add the respective Listeners.
*/
private void initHUD() {
Table hudTable = new Table();
hudTable.setFillParent(true);
Button pauseButton = new Button(new TextureRegionDrawable(
new TextureRegion(game.getAssetManager().get("pause.png", Texture.class))));
scoreText = new Label("0:00", skin);
scoreText.setFontScale(FONT_SCALE, FONT_SCALE);
pauseButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
model.togglePause();
}
});
hudTable.top();
hudTable.add(scoreText).size(HUD_ELEMENTS_SIZE, HUD_ELEMENTS_SIZE).expandX()
.left().fill().padLeft(HORIZONTAL_PAD).padTop(VERTICAL_PAD);
hudTable.add(pauseButton).size(HUD_ELEMENTS_SIZE, HUD_ELEMENTS_SIZE).fill()
.padRight(HORIZONTAL_PAD).padTop(VERTICAL_PAD);
this.addActor(hudTable);
}
示例5: pauseGame
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; //导入依赖的package包/类
private void pauseGame() {
if (paused)
return;
paused = true;
final Window.WindowStyle pauseWindowStyle = new Window.WindowStyle();
pauseWindowStyle.titleFont = game.getFonts().get("moonhouse64");
pauseWindowStyle.background = new TextureRegionDrawable(new TextureRegion(background));
pauseWindow = new PauseWindow(pauseWindowStyle, game.getFonts().get("moonhouse64"), new Runnable() {
@Override
public void run() {
unpauseGame();
}
}, new Runnable() {
@Override
public void run() {
save();
}
}, game, uiAssets, button);
pauseWindow.setBounds(viewport.getWorldWidth() / 2 - viewport.getWorldWidth() / 3, viewport.getWorldHeight() / 2 - viewport.getWorldHeight() / 3, viewport.getWorldWidth() / 3 * 2, viewport.getWorldHeight() / 3 * 2);
stage.addActor(pauseWindow);
}
示例6: build
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; //导入依赖的package包/类
@Override
public void build(Group group) {
pauseButtonTexture = new TextureRegionDrawable(new TextureRegion(new Texture("pause.png")));
backButtonTexture = new TextureRegionDrawable(new TextureRegion(new Texture("back.png")));
pauseButton = new VisImageButton(pauseButtonTexture);
pauseButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
((WorldSimulator)getController()).toggleOverlayMenu();
}
});
pauseButton.setWidth(widthVal.get(pauseButton));
pauseButton.setHeight(heightVal.get(pauseButton));
group.addActor(pauseButton);
}
示例7: setObjectives
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; //导入依赖的package包/类
public void setObjectives(Objective[] objectives, boolean[] objectiveStatus)
{
this.objectives = objectives;
this.objectiveStatus = objectiveStatus;
if(objectives.length != objectiveStatus.length)
throw new IllegalArgumentException();
getContentTable().clearChildren();
getBackground().setMinHeight(200 + 100 * objectives.length);
getContentTable().setDebug(false);
for(int i = 0; i < objectives.length; i++)
{
ImageButton imgCheck = new ImageButton(new TextureRegionDrawable(
new TextureRegion((Texture)
hexpert.assetManager.get(objectiveStatus[i] ? TEXTURE_CORRECT : TEXTURE_BAD
))));
Label labelObjective = new Label(objectives[i].toString(hexpert.i18NBundle), getSkin());
getContentTable().add(imgCheck).width(100).height(80);
imgCheck.getImageCell().expand().fill();
getContentTable().add(labelObjective);
getContentTable().row();
}
}
示例8: MenuScreen
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; //导入依赖的package包/类
public MenuScreen(final LePendu game) {
super(game);
titleImg = new Image(new TextureRegionDrawable(game.atlas.findRegion("title")));
playBtn = new ImageButton(new TextureRegionDrawable(game.atlas.findRegion("playBtn")));
decosImg = new Image(new TextureRegionDrawable(game.atlas.findRegion("decos")));
table.add(titleImg).top().padTop(169);
table.row();
table.add(playBtn).expandY();
table.row();
table.add(decosImg).bottom().padBottom(50);
playBtn.addListener(new ChangeListener() {
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
game.setScreen(new DifficultyScreen(game));
}
});
}
示例9: KeyboardActor
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; //导入依赖的package包/类
public KeyboardActor(final PlayScreen playScreen) {
alphabet = new Texture("alphabet.png");
for (int i = 0 ; i < 26 ; i++) {
if (i%7 == 0) {
hg = new HorizontalGroup();
this.addActor(hg);
}
final char character = (char) (i + 65);
button = new ImageButton(new TextureRegionDrawable(new TextureRegion(alphabet, i * 90, 0, 90, 90)));
button.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
playScreen.proposeLetter(character);
}
});
hg.addActor(button);
}
}
示例10: render
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; //导入依赖的package包/类
/**------------------------RENDER------------------------**/
@Override
public void render(float f)
{
//Debug
//stage.setDebugAll(true);
//Clear Screen
Gdx.gl.glClearColor(0.2f, 0.2f, 0.2f, 1);
Gdx.gl.glClear(GL30.GL_COLOR_BUFFER_BIT);
//Set background image
rootTable.background(new TextureRegionDrawable(new TextureRegion(TextureManager.menuBackground)));
//Draw stage
stage.act(Gdx.graphics.getDeltaTime());
stage.draw();
/*------------------SWITCH TO FULLSCREEN AND BACK------------------*/
super.changeToFullScreenOnF12();
}
示例11: createInfoLabel
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; //导入依赖的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);
}
示例12: createMobileMoveButton
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; //导入依赖的package包/类
private void createMobileMoveButton() {
float screenWidth = Gdx.graphics.getWidth();
float screenHeight = Gdx.graphics.getHeight();
moveButton = new Button(skin);
moveButton.getStyle().down = new TextureRegionDrawable(AssetManager.getInstance().getTextureRegion("default")).tint(MOBILE_BUTTON_DOWN_COLOR);
moveButton.getStyle().up = new TextureRegionDrawable(AssetManager.getInstance().getTextureRegion("default")).tint(MOBILE_BUTTON_UP_COLOR);
moveButton.setSize(screenWidth * 0.35f, screenHeight * 0.2f);
moveButton.setPosition(screenWidth / 32, screenHeight / 32f);
moveButton.addListener(new com.badlogic.gdx.scenes.scene2d.InputListener() {
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
boolean isTutorial = DAO.getInstance().getBoolean(DAO.IS_NEW_KEY, true);
if (Globals.getGameState() == Game.State.WAIT_FOR_INPUT) {
Globals.setGameState(Game.State.RUNNING);
}
if (Globals.getGameState() == Game.State.RUNNING) {
movePointer = pointer;
}
return true;
}
});
stage.addActor(moveButton);
}
示例13: loadAsyncImages
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; //导入依赖的package包/类
protected void loadAsyncImages()
{
// Check if we need to load level icons and if they are loaded show them.
if (!this.asyncImages.isEmpty())
{
AssetManager assMan = AssMan.getAssMan();
ArrayList<String> texturePaths =
new ArrayList<>(this.asyncImages.keySet());
for (String texturePath : texturePaths)
{
if (assMan.update()
|| assMan.isLoaded(texturePath))
{
Texture texture = assMan.get(texturePath);
texture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
this.asyncImages.get(texturePath)
.setDrawable(new TextureRegionDrawable(new TextureRegion(texture)));
this.asyncImages.remove(texturePath);
}
}
}
}
示例14: getConfigurableAttributes
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; //导入依赖的package包/类
@Override
public List<ConfigurableAttribute<?>> getConfigurableAttributes() {
List<ConfigurableAttribute<?>> attrs = new ArrayList<>();
attr(attrs, new Meta.Object("Translation X", "Transform"), () -> ((Float)transform().getValues()[Reference.Matrix4Alias.TranslationX]).intValue(), (val) -> { transform().getValues()[Reference.Matrix4Alias.TranslationX] = Float.parseFloat(val.toString()); }, ConfigControl.NUMBERSELECTOR, Float::parseFloat);
attr(attrs, new Meta.Object("Translation Y", "Transform"), () -> ((Float)transform().getValues()[Reference.Matrix4Alias.TranslationY]).intValue(), (val) -> { transform().getValues()[Reference.Matrix4Alias.TranslationY] = Float.parseFloat(val.toString()); }, ConfigControl.NUMBERSELECTOR, Float::parseFloat);
attr(attrs, new Meta.Object("Translation Z", "Transform"), () -> ((Float)transform().getValues()[Reference.Matrix4Alias.TranslationZ]).intValue(), (val) -> { transform().getValues()[Reference.Matrix4Alias.TranslationZ] = Float.parseFloat(val.toString()); }, ConfigControl.NUMBERSELECTOR, Float::parseFloat);
attr(attrs, new Meta.Object("Rotation Roll", "Transform"), () -> ((Float)rotRoll).intValue(), (val) -> { rotRoll =Float.parseFloat(val.toString()); updateTransform(); }, ConfigControl.NUMBERSELECTOR, Float::parseFloat);
attr(attrs, new Meta.Object("Rotation Pitch", "Transform"), () -> ((Float)rotPitch).intValue(), (val) -> { rotPitch=Float.parseFloat(val.toString()); updateTransform(); }, ConfigControl.NUMBERSELECTOR, Float::parseFloat);
attr(attrs, new Meta.Object("Rotation Yaw", "Transform"), () -> ((Float)rotYaw).intValue(), (val) -> { rotYaw =Float.parseFloat(val.toString()); updateTransform(); }, ConfigControl.NUMBERSELECTOR, Float::parseFloat);
attr(attrs, new Meta.Object("Scale X", "Transform"), () -> ((Float)transform().getValues()[Reference.Matrix4Alias.ScaleX]).intValue(), (val) -> { transform().getValues()[Reference.Matrix4Alias.ScaleX] = Float.parseFloat(val.toString()); }, ConfigControl.NUMBERSELECTOR, Float::parseFloat);
attr(attrs, new Meta.Object("Scale Y", "Transform"), () -> ((Float)transform().getValues()[Reference.Matrix4Alias.ScaleY]).intValue(), (val) -> { transform().getValues()[Reference.Matrix4Alias.ScaleY] = Float.parseFloat(val.toString()); }, ConfigControl.NUMBERSELECTOR, Float::parseFloat);
attr(attrs, new Meta.Object("Scale Z", "Transform"), () -> ((Float)transform().getValues()[Reference.Matrix4Alias.ScaleZ]).intValue(), (val) -> { transform().getValues()[Reference.Matrix4Alias.ScaleZ] = Float.parseFloat(val.toString()); }, ConfigControl.NUMBERSELECTOR, Float::parseFloat);
ConfigurableAttribute modelAttr = attr(attrs, new Meta.Object("Model", "Rendering"), this::getModelRef, this::setModel, ConfigControl.SELECTIONLIST);
String[] modelRefs = Argent.content.getAllRefs(Model.class);
SearchableList.Item.Data[] modelItems = new SearchableList.Item.Data[modelRefs.length];
int index = 0;
for (String ref : modelRefs)
modelItems[index++] = new SearchableList.Item.Data<>(new TextureRegionDrawable(new TextureRegion(net.ncguy.argent.utils.SpriteCache.pixel())), ref, ref);
modelAttr.addParam("items", SearchableList.Item.Data[].class, modelItems);
return attrs;
}
示例15: getMainMenuButtons
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; //导入依赖的package包/类
public ImageButton.ImageButtonStyle getMainMenuButtons(int number){
ImageButton.ImageButtonStyle s = new ImageButton.ImageButtonStyle();
Texture mainMenuButtonsAtlas = get("MainMenuAtlas.png", Texture.class);
TextureRegion[][] mainMenuButtons = TextureRegion.split(mainMenuButtonsAtlas, mainMenuButtonsAtlas.getWidth() / 2, mainMenuButtonsAtlas.getHeight() / 10);
switch (number){
case 1:
s.up = new TextureRegionDrawable(mainMenuButtons[0][0]);
s.over = new TextureRegionDrawable(mainMenuButtons[0][1]);
s.down = new TextureRegionDrawable(mainMenuButtons[0][1]);
return s;
case 2:
s.up = new TextureRegionDrawable(mainMenuButtons[1][0]);
s.over = new TextureRegionDrawable(mainMenuButtons[1][1]);
s.down = new TextureRegionDrawable(mainMenuButtons[1][1]);
return s;
case 3:
s.up = new TextureRegionDrawable(mainMenuButtons[2][0]);
s.over = new TextureRegionDrawable(mainMenuButtons[2][1]);
s.down = new TextureRegionDrawable(mainMenuButtons[2][1]);
return s;
}
return null;
}