Java 类com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable 实例源码

项目:StickFlick    文件:Arrow.java   
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);
}
项目:droidtowers    文件:SplashScene.java   
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);
}
项目:feup-lpoo-armadillo    文件:CustomizeMenuScreen.java   
/**
 * 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();
}
项目:feup-lpoo-armadillo    文件:HudMenu.java   
/**
 * 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);
}
项目:Tower-Defense-Galaxy    文件:GameScreen.java   
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);
}
项目:Climatar    文件:PauseView.java   
@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);
}
项目:Hexpert    文件:ObjectiveDialog.java   
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();
    }
}
项目:le-pendu    文件:MenuScreen.java   
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));
        }
    });
}
项目:le-pendu    文件:KeyboardActor.java   
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);
    }
}
项目:Space-Bombs    文件:MenuScreen.java   
/**------------------------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();

}
项目:joe    文件:HUD.java   
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);
}
项目:joe    文件:HUD.java   
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);
}
项目:space-travels-3    文件:Screen.java   
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);
            }
        }
    }
}
项目:Argent    文件:WorldObject.java   
@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;
}
项目:GDefence    文件:AssetLoader.java   
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;
}
项目:GDefence    文件:LevelShopSource.java   
@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;
    }
项目:GDefence    文件:SlotActor.java   
static ImageButtonStyle createStyle(Skin skin, Item prototype/* slot*/) {
        //TextureAtlas icons = LibgdxUtils.assets.get("icons/icons.atlas", TextureAtlas.class);
//      TextureAtlas icons = new TextureAtlas(Gdx.files.internal("icons/icons.atlas"));
        TextureAtlas icons = GDefence.getInstance().assetLoader.get("icons/icons.atlas", TextureAtlas.class);
        TextureRegion image;
        if (/*slot.getPrototype()*/prototype != null) {
            image = icons.findRegion(prototype.getTextureRegion());
        } else {
            image = icons.findRegion("nothing");
        }
        ImageButtonStyle style = new ImageButtonStyle(skin.get(ButtonStyle.class));
        style.imageUp = new TextureRegionDrawable(image);
        style.imageDown = new TextureRegionDrawable(image);

        return style;
    }
项目:cachebox3.0    文件:Validate_Abstract_Icons.java   
private void checkSize(Object object, String fieldName) {
    int width = 0, height = 0;

    if (object instanceof TextureRegionDrawable) {
        TextureRegionDrawable trd = (TextureRegionDrawable) object;
        width = (int) trd.getMinWidth();
        height = (int) trd.getMinHeight();
    }

    if (width < getMinWidth() || width > getMaxWidth()) {
        wrongBitmapsSize.append(fieldName);
        wrongBitmapsSize.append(" width: " + width);
        wrongBitmapsSize.append("   => The width should be between " + getMinWidth() + " and " + getMaxWidth() + "  !");
        wrongBitmapsSize.append(" \n");
    }

    if (height < getMinHeight() || height > getMaxHeight()) {
        wrongBitmapsSize.append(fieldName);
        wrongBitmapsSize.append(" height: " + height);
        wrongBitmapsSize.append("   => The height should be between " + getMinHeight() + " and " + getMaxHeight() + "  !");
        wrongBitmapsSize.append(", \n");
    }
}
项目:cachebox3.0    文件:StageManager.java   
public static void setMainStage(NamedStage stage) {
    mainStage = stage;

    if (false && mainStage instanceof ViewManager) {
        // add scaled drawable to batch for non throwing exception with scaled drawing!
        CompassStyle compassStyle = VisUI.getSkin().get("compassViewStyle", CompassViewStyle.class);
        if (compassStyle.arrow != null)
            batch.registerScaledDrawable(((TextureAtlas.AtlasRegion) ((TextureRegionDrawable) compassStyle.arrow).getRegion()).name);

        if (compassStyle.scale != null)
            batch.registerScaledDrawable(((TextureAtlas.AtlasRegion) ((TextureRegionDrawable) compassStyle.scale).getRegion()).name);

        if (compassStyle.frameCompasAlign != null)
            batch.registerScaledDrawable(((TextureAtlas.AtlasRegion) ((TextureRegionDrawable) compassStyle.frameCompasAlign).getRegion()).name);

        if (compassStyle.frameNorthOrient != null)
            batch.registerScaledDrawable(((TextureAtlas.AtlasRegion) ((TextureRegionDrawable) compassStyle.frameNorthOrient).getRegion()).name);

        if (compassStyle.frameUserRotate != null)
            batch.registerScaledDrawable(((TextureAtlas.AtlasRegion) ((TextureRegionDrawable) compassStyle.frameUserRotate).getRegion()).name);

    }

    // add mainStage to input processor
    if (inputMultiplexer != null) addNonDoubleInputProzessor(mainStage);
}
项目:cachebox3.0    文件:SkinLoaderTask.java   
private void storeAttributePng(SvgSkin skin, AttributesStyle style, FileHandle attFileHandle, Attributes value) {

        String imageName = value.getImageName() + ".png";
        EventHandler.fire(new IncrementProgressEvent(1, "generate attribute image: " + imageName));
        FileHandle storeFile = attFileHandle.child(imageName);
        if (storeFile.exists()) return;

        TextureRegionDrawable drawable = (TextureRegionDrawable) value.getDrawable(style);
        if (drawable == null) return;
        ScaledSvg scaledSvg = skin.get(drawable.getName(), ScaledSvg.class);
        Bitmap bitmap = null;
        try {
            FileHandle svgFile = skin.skinFolder.child(scaledSvg.path);
            bitmap = PlatformConnector.getSvg(scaledSvg.getRegisterName(), svgFile.read(), PlatformConnector.SvgScaleType.DPI_SCALED, scaledSvg.scale);
        } catch (IOException e) {
            log.error("", e);
        }
        StoreSvg storeSvg = (StoreSvg) bitmap;
        storeSvg.store(storeFile);
        log.debug("store {} png", bitmap);
    }
项目:cocos-ui-libgdx    文件:CocoStudioUIEditor.java   
public Drawable findDrawable(ObjectData option, String name) {

        if (option.isScale9Enable()) {// 九宫格支持
            TextureRegion textureRegion = findTextureRegion(option, name);
            NinePatch np = new NinePatch(textureRegion,
                option.getScale9OriginX(),
                textureRegion.getRegionWidth() - option.getScale9Width() - option.getScale9OriginX(),
                option.getScale9OriginY(),
                textureRegion.getRegionHeight() - option.getScale9Height() - option.getScale9OriginY());

            np.setColor(getColor(option.getCColor(), option.getAlpha()));
            return new NinePatchDrawable(np);
        }

        TextureRegion tr = findTextureRegion(option, name);

        if (tr == null) {
            return null;
        }

        return new TextureRegionDrawable(tr);
    }
项目:cocos-ui-libgdx    文件:CCSliderTest.java   
@Test
@NeedGL
public void shouldParseSliderBar() throws Exception {
    CocoStudioUIEditor editor = new CocoStudioUIEditor(
        Gdx.files.internal("slideBar/MainScene.json"), null, null, null, null);

    Group group = editor.createGroup();
    Slider slider = group.findActor("Slider_1");
    assertThat(slider.getWidth(), is(200f));
    assertThat(slider.getHeight(), is(14f));
    assertThat(slider.getValue(), is(50f));
    Slider.SliderStyle style = slider.getStyle();
    assertThat(style.knob, instanceOf(TextureRegionDrawable.class));
    assertThat(style.background, instanceOf(TextureRegionDrawable.class));
    assertThat(style.knobBefore, instanceOf(TextureRegionDrawable.class));
    //assertThat(style.disabledKnob, instanceOf(TextureRegionDrawable.class));
   // assertThat(style.knobDown, instanceOf(TextureRegionDrawable.class));
}
项目:gdx-texture-packer-gui    文件:SourceImage.java   
@Override
protected void setStage(Stage stage) {
    super.setStage(stage);

    if (!initialized && stage != null) {
        initialized = true;
        texture = new Texture(pixmap);
        image.setDrawable(new TextureRegionDrawable(new TextureRegion(texture)));
    }
    if (initialized && stage == null) {
        initialized = false;
        texture.dispose();
        texture = null;
        image.setDrawable(null);
    }
}
项目:rectball    文件:BallActor.java   
public BallActor(BoardActor board, Ball ball, TextureAtlas atlas) {
    this.board = board;
    this.ball = ball;
    this.atlas = atlas;
    setScaling(Scaling.fit);
    addListener(new InputListener() {
        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            setSelected(!isSelected());
            return true;
        }
    });

    grayDrawable = new TextureRegionDrawable(atlas.findRegion("ball_gray"));
    colorDrawables = new HashMap<>();
    for (BallColor color : BallColor.values()) {
        colorDrawables.put(color, new TextureRegionDrawable(atlas.findRegion("ball_" + color.toString().toLowerCase())));
    }
}
项目:GdxDemo3D    文件:GameSpeedController.java   
public GameSpeedController(TextureAtlas buttonAtlas) {
    btnPauseStyle = new ImageButton.ImageButtonStyle();
    btnPauseStyle.up = new TextureRegionDrawable(buttonAtlas.findRegion("pause-up"));
    btnPauseStyle.down = new TextureRegionDrawable(buttonAtlas.findRegion("pause-down"));

    btnPlayStyle = new ImageButton.ImageButtonStyle();
    btnPlayStyle.up = new TextureRegionDrawable(buttonAtlas.findRegion("play-up"));
    btnPlayStyle.down = new TextureRegionDrawable(buttonAtlas.findRegion("play-down"));

    btnSlowStyle = new ImageButton.ImageButtonStyle();
    btnSlowStyle.up = new TextureRegionDrawable(buttonAtlas.findRegion("slow-up"));
    btnSlowStyle.down = new TextureRegionDrawable(buttonAtlas.findRegion("slow-down"));

    imageButton = new ImageButton(btnPauseStyle);

    add(imageButton);

    imageButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            setGameSpeed();
            event.cancel();
        }
    });
}
项目:GdxDemo3D    文件:GameStage.java   
public LayerController(TextureAtlas buttonAtlas) {
    Slider.SliderStyle sliderStyle = new Slider.SliderStyle();
    sliderStyle.knob = new TextureRegionDrawable(buttonAtlas.findRegion("slider-knob-up"));
    sliderStyle.knobDown = new TextureRegionDrawable(buttonAtlas.findRegion("slider-knob-down"));
    sliderStyle.knobOver = new TextureRegionDrawable(buttonAtlas.findRegion("slider-knob-down"));
    sliderStyle.background = new TextureRegionDrawable(buttonAtlas.findRegion("slider-background"));

    slider = new Slider(minLayer, maxLayer, 1, true, sliderStyle);
    slider.setValue(maxLayer);
    slider.setAnimateDuration(0.1f);

    slider.addCaptureListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            setLayer((int) slider.getValue());
        }
    });
    add(slider).height(300);
}
项目:umbracraft    文件:Drawables.java   
/** Call to initialize all the drawables. */
public static void init() {
    if (initialized) {
        return;
    }
    Texture texture = new Texture(Gdx.files.internal("editor/skin.png"));
    drawables = new ObjectMap<String, TextureRegionDrawable>();
    drawables.put("transparent", new TextureRegionDrawable(new TextureRegion(texture, 0, 0, 0, 0)));
    drawables.put("black", new TextureRegionDrawable(new TextureRegion(texture, 0, 0, 1, 1)));
    drawables.put("yellow", new TextureRegionDrawable(new TextureRegion(texture, 1, 0, 1, 1)));
    drawables.put("blue", new TextureRegionDrawable(new TextureRegion(texture, 2, 0, 1, 1)));
    drawables.put("white", new TextureRegionDrawable(new TextureRegion(texture, 8, 0, 1, 1)));
    drawables.put("entity", new TextureRegionDrawable(new TextureRegion(texture, 0, 1, 16, 16)));
    if (Game.assets() != null) {
        skin = Game.assets().get("skin/skin.atlas", TextureAtlas.class);
        faces = Game.assets().get("faces/faces.atlas", TextureAtlas.class);
    }
    initialized = true;
}
项目:umbracraft    文件:AnimationPreviewFrame.java   
/** Updates the frame's image. Ensures the file exists before attempting to
 * set the drawable.
 * @param definition
 * @param frame */
public void update(AnimationDefinition definition, AnimationFrameDefinition frame) {
    if (definition != null && definition.filename != null && definition.filename.length() > 0) {
        final String path = "sprites/animations/" + definition.filename + ".png";
        FileHandle handle = null;
        if (Gdx.files.internal(path).exists()) {
            handle = Gdx.files.internal(path);
        } else {
            final String extPath = Editor.db().config().projectPath + Editor.db().config().spritePath + definition.filename + ".png";
            if (Gdx.files.absolute(extPath).exists()) {
                handle = Gdx.files.absolute(extPath);
            }
        }
        if (handle != null) {
            Texture texture = new Texture(handle);
            TextureRegion region = new TextureRegion(texture, frame.x * definition.width + (frame.mirror ? definition.width : 0), frame.y * definition.height, frame.mirror ? -definition.width : definition.width, definition.height);
            setDrawable(new TextureRegionDrawable(region));
        }

    }

}
项目:StickFlick    文件:Mage.java   
public Mage(String name, int health, AnimationLoader anims, int posX, int posY){
    super(name, health,anims);

       orb_shot = Gdx.audio.newSound(Gdx.files.internal("data/sounds/mage_shoot.mp3"));
       SFXVolume = prefs.getInteger("SFXVolume") * 0.01f;

    currentanim = anims.getAnim("mageright");
       currentframe = currentanim.getKeyFrame(animationStateTime, true);
       enemyDrawable = new TextureRegionDrawable(currentframe);

    // Create enemy Image/Actor
    enemy = new Image(enemyDrawable);
    enemy.setX(posX);
    enemy.setY(posY);
    enemy.setScale(scale);

    scale = ((Gdx.graphics.getHeight() - getPosition().y) / 2000);
    enemy.setScale(scale);
}
项目:BlockJump    文件:GameScreen.java   
public void createPauseMenu() {
    pauseMenuStage = new Stage();
    // pauseMenuStage.setViewport(fit);

    pauseMenuTable = new Table();
    pauseMenuTable.setFillParent(true);
    pauseMenuStage.addActor(pauseMenuTable);

    TextButtonStyle style = new TextButtonStyle();
    style.up = new TextureRegionDrawable(buttons[0]); // 1080 x 300
    style.down = new TextureRegionDrawable(buttons[0]);
    style.font = new BitmapFont();

    resumeButton = new Button(style);
    pauseMenuTable.add(resumeButton);

    resumeButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            resumeCall();
        }
    });
}
项目:StickFlick    文件:BoilingOil.java   
public BoilingOil(AnimationLoader anims, float posX, float posY){
    super("boiling_oil", 0, anims);
    scale = 0.5f;
    mscale = 1f;

    animationStateTime = 0;
    currentanim = anims.getAnim("boilingOil");
    currentframe = currentanim.getKeyFrame(animationStateTime, true);
    powerUpDrawable = new TextureRegionDrawable(currentframe);

    // Create enemy Image/Actor
    bOil = new Image(powerUpDrawable);
    bOil.setX(posX);
    bOil.setY(posY);
    bOil.setScale(scale);

}
项目:StickFlick    文件:Archer.java   
public Archer(String name, int health, AnimationLoader anims, int posX, int posY){
    super(name, health,anims);

       arrowShot= Gdx.audio.newSound(Gdx.files.internal("data/sounds/arrow_shot.mp3"));
       SFXVolume = prefs.getInteger("SFXVolume") * 0.01f;

    currentanim = anims.getAnim("archerright");
       currentframe = currentanim.getKeyFrame(animationStateTime, 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) / 2000);
    enemy.setScale(scale);
}
项目:ragnar    文件:MenuTable.java   
public MenuTable () {
    GuiStyles.init();
       Texture tex = new Texture(Gdx.files.internal("wave.png"));
       tex.setWrap(Texture.TextureWrap.Repeat, Texture.TextureWrap.Repeat);
       setBackground(new TextureRegionDrawable(new TextureRegion(tex, (int)Constants.WAVE_WIDTH, (int)Constants.WAVE_HEIGHT)));

    playButton = new PlayButton();
    //settings = new TextButton("Settings", GuiStyles.largeButtonStyle);
    //highscore = new TextButton("Highscore", GuiStyles.largeButtonStyle);
    credits = new TextButton("Credits", GuiStyles.largeButtonStyle);
       quit = new QuitApp();
       optionsButton = new OptionsButton();

    add(playButton).pad(20);
    row();
    add(optionsButton).pad(20);
    row();
    add(credits).pad(20);
       row();
       add(quit).pad(20);

    addFunctionality();
}
项目:libgdxcn    文件:CpuSpriteBatchTest.java   
public void create () {
    Batch batch = new CpuSpriteBatch();
    // batch = new SpriteBatch();

    stage = new Stage(new ExtendViewport(500, 500), batch);

    Gdx.input.setInputProcessor(stage);

    texture = new Texture("data/bobargb8888-32x32.png");
    texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    TextureRegionDrawable drawable = new TextureRegionDrawable(new TextureRegion(texture));

    for (int i = 0; i < NUM_GROUPS; i++) {
        Group group = createActorGroup(drawable);
        stage.addActor(group);
    }
}
项目:master-maze    文件:ControllerButton.java   
/**
 * Button for the controller overlay.
 * @param key The key that it will trigger.
 * @param flipX Flip image horizontally.
 * @param flipY Flip image vertically.
 * @param rotate Rotate 90 degrees.
 */
public ControllerButton(int key, boolean flipX, boolean flipY, boolean rotate) {
    this.key = key;
    ImageButton.ImageButtonStyle style = new ImageButton.ImageButtonStyle();
    TextureRegion t = Assets.getGameTexture("controller_button");
    t.flip(flipX, flipY);
    // Rotate 90 degrees (u1 = u1, v1 = v2, u2 = u2, v2 = v1)
    if(rotate) {
        float v2 = t.getV2();
        float v1 = t.getV();
        t.setV(v2);
        t.setV2(v1);
    }

    style.imageUp = new TextureRegionDrawable(t);

    this.button = new ImageButton(style);
    this.button.addListener(new ControllerButtonListener(this));
}
项目:MathAttack    文件:AbstractWorldScene2d.java   
/**
 * Sets the background texture.
 *
 * @param textureBackground the texture background
 * @param scaling the scaling
 * @param fillParent the fill parent
 * @param touchable the touchable
 */
public void setBackgroundTexture(TextureRegion textureBackground,
        Scaling scaling, boolean fillParent, boolean touchable) {
    Drawable tBg = new TextureRegionDrawable(textureBackground);
    Image imgbg = new Image(tBg, scaling);
    this.imageBackground = imgbg;
    imgbg.setFillParent(fillParent);

    if (!touchable) {
        imgbg.setTouchable(Touchable.disabled);
    }

    addActor(imgbg);
    //
    MtxLogger.log(logActive, true, logTag, "World bacground image set");
}
项目:Vloxlands    文件:ItemSlot.java   
private static ImageButtonStyle createStyle(ItemStack stack) {
    Texture tex = Vloxlands.assets.get("img/icons.png", Texture.class);
    TextureRegion region = null;
    if (!stack.isNull()) region = new TextureRegion(tex, stack.getItem().getIconX() * Item.SIZE, stack.getItem().getIconY() * Item.SIZE, Item.SIZE, Item.SIZE);
    else region = new TextureRegion(tex, 5 * Item.SIZE, Item.SIZE, Item.SIZE, Item.SIZE); // default
                                                                                                                                                                                // transparent
                                                                                                                                                                                // space

    ImageButtonStyle style = new ImageButtonStyle(Vloxlands.skin.get("image", ButtonStyle.class));
    style.imageUp = new TextureRegionDrawable(region);
    style.imageUp.setMinWidth(size);
    style.imageUp.setMinHeight(size);
    style.imageDown = new TextureRegionDrawable(region);
    style.imageDown.setMinWidth(size);
    style.imageDown.setMinHeight(size);
    return style;
}
项目:HAW-SE2-projecthorse    文件:Puzzle.java   
/**
 * erstelle ein Zurückbutton. um zurück zur Bilderauswahl gelangen zu können
 * rufe die Methode addListener(...) auf, füge den Button in die zweite
 * Stage
 */
private void createButtons() {
    ImageButton buttonBack = new ImageButton(new TextureRegionDrawable(
            AssetManager.getTextureRegion("ui", "backIcon")));

    buttonBack.setHeight(95);
    buttonBack.setWidth(95);

    buttonBack.setPosition(PuzzleManager.getMyXPos()
            + getPuzzleManager().getMyWidth() - buttonBack.getWidth(),
            PuzzleManager.getMyYPos() + getPuzzleManager().getMyHeight());

    addListener(buttonBack);

    PuzzleManager.addToStage(PuzzleManager.getSecondstage(), buttonBack);

}
项目:HAW-SE2-projecthorse    文件:Popup.java   
/**
 * Initalisierung des standart backgrounds.
 */
private void createBackgroundImage() {

    backgroundImage = new Image(new TextureRegionDrawable(AssetManager.getTextureRegion("ui", "panel_beige")));

    backgroundImage.setWidth(popupWidth);
    // backgroundImage.setHeight(popupHeight);
    // backgroundImage.setY((height / 2) - popupHeight / 2);
    backgroundImage.addListener(new InputListener() {
        @Override
        public boolean touchDown(final InputEvent event, final float x, final float y, final int pointer,
                final int button) {
            event.cancel();
            return true;
        }
    });
    content.addActor(backgroundImage);
}
项目:HAW-SE2-projecthorse    文件:ButtonLarge.java   
/**
 * Erstellt einen ImageTextButtonStyle anhand eines Button Stils.
 * 
 * @param color
 *            Der Button Stil
 * @return Das ImageTextButtonStyle Objekt
 */
private static ImageTextButtonStyle getImageButtonStyle(
        final ButtonColor color) {

    Drawable drawable = new TextureRegionDrawable(
            AssetManager.getTextureRegion("ui", color.getFileName()));

    ImageTextButtonStyle imageButtonStyle = new ImageTextButton.ImageTextButtonStyle();
    imageButtonStyle.down = drawable;
    imageButtonStyle.up = drawable;

    imageButtonStyle.font = AssetManager.getTextFont(color.getFontSize());
    imageButtonStyle.fontColor = color.getFontColor();

    return imageButtonStyle;
}