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

项目:OmiClub    文件:GraphicsLoader.java   
public static Map<String, ImageButton> getButtons(){
    if(!buttonMap.isEmpty()){
        return buttonMap;
    }
    buttonMap.put("singleBtn", new ImageButton(
            new SpriteDrawable(buttonAtlas.createSprite("Single_N")),
            new SpriteDrawable(buttonAtlas.createSprite("Single_P"))));
    buttonMap.put("hostBtn", new ImageButton(
            new SpriteDrawable(buttonAtlas.createSprite("Host_N")),
            new SpriteDrawable(buttonAtlas.createSprite("Host_P"))));
    buttonMap.put("joinBtn", new ImageButton(
            new SpriteDrawable(buttonAtlas.createSprite("Join_N")),
            new SpriteDrawable(buttonAtlas.createSprite("Join_P"))));
    buttonMap.put("exitBtn", new ImageButton(
            new SpriteDrawable(buttonAtlas.createSprite("Exit_N")),
            new SpriteDrawable(buttonAtlas.createSprite("Exit_P"))));
    buttonMap.put("aboutBtn", new ImageButton(
            new SpriteDrawable(buttonAtlas.createSprite("About_N")),
            new SpriteDrawable(buttonAtlas.createSprite("About_P"))));
    buttonMap.put("settingsBtn", new ImageButton(
            new SpriteDrawable(buttonAtlas.createSprite("Sett_N")),
            new SpriteDrawable(buttonAtlas.createSprite("Sett_P"))));

    return buttonMap;
}
项目:Teleport-Ball    文件:HelpButton.java   
public HelpButton(final Application app, final MenuHud menuHud, final TextureAtlas atlas)
{
    drawableUp = new SpriteDrawable(atlas.createSprite("help-up"));
    drawableDown = new SpriteDrawable(atlas.createSprite("help-down"));
    applyFilter();

    button = new ImageButton(drawableUp, drawableDown);

    button.addListener(new ClickListener()
    {
        @Override
        public void clicked (InputEvent event, float x, float y)
        {
            menuHud.removeAllActorsFromStage();
            ColorOverlay.enabled = false;
            app.setScreen(new HelpScreen(app, atlas));
        }
    });
}
项目:Teleport-Ball    文件:PlayButton.java   
public PlayButton(final Application app, final TextureAtlas atlas)
{
    drawableUp = new SpriteDrawable(atlas.createSprite("pb-up"));
    drawableDown = new SpriteDrawable(atlas.createSprite("pb-down"));
    applyFilter();

    button = new ImageButton(drawableUp, drawableDown);
    button.addListener(new ClickListener()
    {
        @Override
        public void clicked (InputEvent event, float x, float y)
        {
            app.setScreen(new GameScreen(app, atlas));
        }
    });
}
项目:Teleport-Ball    文件:HomeButton.java   
public HomeButton(final Application app, final TextureAtlas atlas)
{
    drawableUp = new SpriteDrawable(atlas.createSprite("home-up"));
    drawableDown = new SpriteDrawable(atlas.createSprite("home-down"));

    applyFilter();

    button = new ImageButton(drawableUp, drawableDown);

    button.addListener(new ClickListener()
    {
        @Override
        public void clicked(InputEvent event, float x, float y)
        {
            Ball.died = false;
            GameScreen.adAlreadyShowed++;
            app.setScreen(new MenuScreen(app));
        }
    });
}
项目:Teleport-Ball    文件:RestartButton.java   
public RestartButton(final Player player, final Ball ball, final TextureAtlas atlas)
{
    drawableUp = new SpriteDrawable(atlas.createSprite("rb-normal"));
    drawableDown = new SpriteDrawable(atlas.createSprite("rb-down"));
    applyFilter();

    button = new ImageButton(drawableUp, drawableDown);

    button.addListener(new ClickListener()
    {
        @Override
        public void clicked(InputEvent event, float x, float y)
        {
            Ball.died = false;
            GameScreen.adAlreadyShowed++;
            ball.reset();
            player.reset();
        }
    });
}
项目:cachebox3.0    文件:ImageLoader.java   
public void setSprite(Sprite sprite, boolean reziseHeight) {

        State = 7;
        inLoad = false;
        spriteWidth = sprite.getWidth();
        spriteHeight = sprite.getHeight();

        if (this.resizeListener != null) {
            float proportionWidth = resizeWidth / spriteWidth;
            if (proportionWidth > CB.getScalefactor()) {
                proportionWidth = CB.getScalefactor();
            }

            float newWidth = spriteWidth * proportionWidth;//* UI_Size_Base.that.getScale();
            float newHeight = spriteHeight * proportionWidth;//* UI_Size_Base.that.getScale();
            sprite.scale(proportionWidth);
            this.resizeListener.sizechanged(newWidth, newHeight);

        }

        mDrawable = new SpriteDrawable(sprite);
    }
项目:clouboy    文件:AbstractScreen.java   
protected Actor createAchievementButton() {
  final Image button =
          new Image(new SpriteDrawable(new Sprite(assets.get(Assets.TEX_BUTTON_ACHIEVEMENTS, Texture.class)))) {
            @Override
            public void act(float delta) {
              setVisible(game.getSocialManager().isConnected());
              super.act(delta);
            }
          };
  button.addCaptureListener(new TitleButtonListener() {
    @Override
    protected void clicked() {
      game.getSocialManager().showAchievements();
    }
  });
  button.getColor().a = BUTTON_TRANSPARENCY;
  return button;
}
项目:clouboy    文件:AbstractScreen.java   
protected Actor createLadderButton() {
  final Image button = new Image(new SpriteDrawable(new Sprite(assets.get(Assets.TEX_BUTTON_LADDER, Texture.class)))) {
    @Override
    public void act(float delta) {
      setVisible(game.getSocialManager().isConnected());
      super.act(delta);
    }
  };
  button.addCaptureListener(new TitleButtonListener() {
    @Override
    protected void clicked() {
      game.getSocialManager().showLadder();
    }
  });
  button.getColor().a = BUTTON_TRANSPARENCY;
  return button;
}
项目:GDXJam    文件:FormationPatternTable.java   
private ImageButton createFormationButton(FormationPatternType pattern, Skin skin){
        ImageButtonStyle style = new ImageButtonStyle(skin.get("default", ButtonStyle.class));

        Sprite sprite = new Sprite(Assets.ui.formationIcons.get(pattern.ordinal()));
        sprite.setSize(26, 26);
        sprite.setColor(Color.BLUE);
        SpriteDrawable drawable = new SpriteDrawable(sprite);

        style.imageUp = drawable;
//      style.imageDown = drawable.tint(Color.CYAN);
        style.imageChecked = drawable.tint(Color.RED);

        ImageButton button = new ImageButton(style);
        button.setUserObject(pattern);
        return button;
    }
项目:Topicos2015-2    文件:MenuScreen.java   
private void initButtons() {
    buttonTexture = new Texture("buttons/button.png");
    downButtonTexture = new Texture("buttons/button-down.png");

    ImageTextButton.ImageTextButtonStyle style = new ImageTextButton.ImageTextButtonStyle();
    style.font = buttonFont;
    style.up = new SpriteDrawable(new Sprite(buttonTexture));
    style.down = new SpriteDrawable(new Sprite(downButtonTexture));

    startButton = new ImageTextButton("  Iniciar  ", style);
    stage.addActor(startButton);

    startButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            // Evento do botão
            game.setScreen(new GameScreen(game));
        }
    });
}
项目:ragnar    文件:KillTable.java   
public void show (String deathMsg, String score, String highscore, int deathType, boolean newHighscore) {
    this.deathMsg.setText(deathMsg);
    this.score.setText(score);
    this.highscore.setText(highscore);
    System.out.println(deathType);
    if (deathType == KillScreen.STABBED) {
        if (RagnarConfig.playerType == 0) {
            deathImg.setDrawable(new SpriteDrawable(new Sprite(Assets.getLoadedTexture(Assets.DEAD_PLAYER_STABBED_PATH))));
        } else {
            deathImg.setDrawable(new SpriteDrawable(new Sprite(Assets.getLoadedTexture(Assets.DEAD_PLAYER_STABBED_GIRL_PATH))));
        }
    }
       else if (deathType == KillScreen.SHOT) {
        if (RagnarConfig.playerType == 0) {
            deathImg.setDrawable(new SpriteDrawable(new Sprite(Assets.getLoadedTexture(Assets.DEAD_PLAYER_PATH))));
        } else {
            deathImg.setDrawable(new SpriteDrawable(new Sprite(Assets.getLoadedTexture(Assets.DEAD_PLAYER_GIRL_PATH))));
        }
    } else {
           deathImg.setDrawable(new SpriteDrawable(Assets.meteorSprite));
           deathImg.setSize(24, 24);
       }
       loadUI(newHighscore);
    sizeImage(deathImg, deathType);

}
项目:craft    文件:TabWidget.java   
private ImageButtonStyle generateTabStyle(String iconId, boolean active) {
  ImageButtonStyle origin = Styles.BTN_TAB;
  if (active) {
    origin = Styles.BTN_TAB_ACTIVE;
  }
  ImageButtonStyle style = new ImageButtonStyle(origin);
  Sprite sprite = new Sprite(SharedAssetManager.get(iconId, Texture.class));
  sprite.setAlpha(0.8f);
  OffsetDrawable drawable = new OffsetDrawable(new SpriteDrawable(sprite));
  drawable.setOffsetX(-Sizes.panelRadius() - 1f);
  style.imageUp = drawable;
  style.imageOver = drawable;
  style.imageUp.setMinHeight(70);
  style.imageUp.setMinWidth(70);
  style.imageOver.setMinHeight(70);
  style.imageOver.setMinWidth(70);
  return style;
}
项目:DreamsLibGdx    文件:SplashScreen.java   
@Override
public void resize(int width, int height) {
    super.resize(width, height);

    Image splashImage = new Image(new SpriteDrawable(new Sprite(splashTexture)), Scaling.stretch, Align.bottom | Align.left);
    splashImage.setWidth(width);
    splashImage.setHeight(height);
    splashImage.getColor().a = 0f;

    splashImage.addAction(sequence(fadeIn(0.5f), run(new Runnable() {
        public void run() {
            game.menuScreen = new MenuScreen(game);
        }
    }), delay(1f, fadeOut(0.5f)), run(new Runnable() {
        public void run() {
            game.setGameState(GameState.GAME_SHOW_MENU);
        }
    })));

    stage.addActor(splashImage);
}
项目:DreamsLibGdx    文件:DebugWindow.java   
public static Window createWindowDebug(ResourcesManager resourcesManager){

        BitmapFont font = (BitmapFont) resourcesManager.get(resourcesManager.DEBUG_FONT);
        font.setScale(1 / 150F);
        font.setUseIntegerPositions(false);
        Window.WindowStyle style = new Window.WindowStyle();
        //style.background = background;
        style.titleFont = font;
        style.titleFontColor=new Color(1, 1, 1, 0.4f);
        Sprite background = new Sprite((Texture) resourcesManager.get(resourcesManager.DEBUG_BACKGROUND));
        background.setSize(10,8);
        background.setOrigin(background.getWidth() / 2, background.getHeight() / 2);
        background.setColor(1,1,1,0.4f);
        style.background= new SpriteDrawable(background);
        Window window = new DebugWindow("", style);
        window.setPosition(0, 0);
        window.setKeepWithinStage(false);
        window.setTransform(false);
        window.setFillParent(true);

        Label.LabelStyle labelStyle= new Label.LabelStyle(font,new Color(1, 1, 1, 1)) ;
        myLabel= new Label("",labelStyle);
        window.add(myLabel).pad(0.2f).width(8);

        return window;
    }
项目:ingress-indonesia-dev    文件:Skin.java   
public Drawable newDrawable(String paramString, Color paramColor)
{
  Drawable localDrawable = getDrawable(paramString);
  if ((localDrawable instanceof TextureRegionDrawable))
  {
    Sprite localSprite1 = new Sprite(((TextureRegionDrawable)localDrawable).getRegion());
    localSprite1.setColor(paramColor);
    return new SpriteDrawable(localSprite1);
  }
  if ((localDrawable instanceof NinePatchDrawable))
  {
    NinePatchDrawable localNinePatchDrawable = new NinePatchDrawable((NinePatchDrawable)localDrawable);
    localNinePatchDrawable.setPatch(new NinePatch(localNinePatchDrawable.getPatch(), paramColor));
    return localNinePatchDrawable;
  }
  if ((localDrawable instanceof SpriteDrawable))
  {
    SpriteDrawable localSpriteDrawable = new SpriteDrawable((SpriteDrawable)localDrawable);
    Sprite localSprite2 = new Sprite(localSpriteDrawable.getSprite());
    localSprite2.setColor(paramColor);
    localSpriteDrawable.setSprite(localSprite2);
    return localSpriteDrawable;
  }
  throw new GdxRuntimeException("Unable to copy, unknown drawable type: " + localDrawable.getClass());
}
项目:MMORPG_Prototype    文件:Icon.java   
public Icon(Texture texture)
{
    sprite = new Sprite(texture);
    drawable = new SpriteDrawable(sprite);
    setWidth(WIDTH_INVENTORY);
    setHeight(HEIGHT_INVENTORY);
    drawable.setMinWidth(WIDTH_INVENTORY);
    drawable.setMinHeight(HEIGHT_INVENTORY);
}
项目:arcadelegends-gg    文件:SettingsScreen.java   
/**
 * Method responsible for initializing the settings menu
 * Called when the screen becomes the current screen of the game
 */
@Override
public void show() {
    cam = new OrthographicCamera();
    viewport = new FitViewport(1920, 1080);
    viewport.setCamera(cam);
    stage = new Stage(viewport);
    stage.setViewport(viewport);
    skin = settingsAssets.styles_json;
    int x = 1920;
    int y = 1080;
    spriteBatch = new SpriteBatch();
    mainbackground = settingsAssets.testmainscreen;
    componentMap = new HashMap<>();
    selectionTexture = settingsAssets.background_textbutton;
    Sprite sprite = new Sprite(selectionTexture);
    selection = new SpriteDrawable(sprite);

    tabbedPane = new SettingsTabbedPane(skin, x, y, componentMap);

    initTabs();

    createVideoTable();
    createAudioTable();

    componentMap.put(btTabVideo, tableVideo);
    componentMap.put(btTabAudio, tableAudio);
    tabbedPane.setCurrentTab(btTabVideo);
    stage.addActor(tabbedPane);

    createBackButton();

    AL.input.setInputProcessor(new InputMultiplexer(stage, this));

}
项目:space-travels-3    文件:UIManager.java   
private static Drawable getDrawable(String path)
{
    Texture texture = new Texture(path);
    texture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);

    return new SpriteDrawable(new Sprite(texture));
}
项目:Teleport-Ball    文件:HelpScreen.java   
@Override
public void show()
{
    app.camera.setToOrtho(false, Constants.V_WIDTH, Constants.V_HEIGHT);
    app.camera.update();
    player = new Player(atlas.createSprite("paddle"), app);
    String path = app.prefs.getString("BG_PATH", "images/paddlandball/bg-red.png");
    bg = new Sprite(app.assets.get(path, Texture.class));

    overlay = new Sprite(app.assets.get("images/helpScreen/helpscreen.png", Texture.class));
    overlay.getTexture().setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);

    bUp = new SpriteDrawable(new Sprite(app.assets.get("images/backButton/back-up.png", Texture.class)));
    bDown = new SpriteDrawable(new Sprite(app.assets.get("images/backButton/back-down.png", Texture.class)));

    bUp.getSprite().getTexture().setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
    bDown.getSprite().getTexture().setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);

    backButton = new ImageButton(bUp, bDown);
    backButton.addListener(new ClickListener()
    {
        @Override
        public void clicked(InputEvent event, float x, float y)
        {
            backButton.remove();
            app.setScreen(new MenuScreen(app));
        }
    });
    backButton.setPosition(20, Constants.V_HEIGHT - backButton.getHeight() - 20);

    stage = new Stage(app.viewport, app.batch);

    stage.addActor(backButton);

    Gdx.input.setInputProcessor(stage);
}
项目:Teleport-Ball    文件:ColorButton.java   
public ColorButton(Sprite spriteDown, Sprite spriteUp)
{
    drawableDown = new SpriteDrawable(spriteDown);
    drawableUp = new SpriteDrawable(spriteUp);

    applyFilter();

    button = new ImageButton(drawableDown, drawableUp);
}
项目:GDefence    文件:AssetLoader.java   
public ImageButton.ImageButtonStyle generateImageButtonSkin(Texture t){
//        t.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);//TODO
        ImageButton.ImageButtonStyle s = new ImageButton.ImageButtonStyle();
//        System.out.println(t.getMinFilter() + " " + t.getMagFilter());
//        System.out.println(new TextureRegionDrawable(new TextureRegion(t)).getRegion().getTexture().getMinFilter());
//        s.up = new TextureRegionDrawable(new TextureRegion(t));
        s.up = new SpriteDrawable(new Sprite(t));
//        s.over = new TextureRegionDrawable(new TextureRegion(t));
//        s.down = new TextureRegionDrawable(new TextureRegion(t));
        return s;

    }
项目:clouboy    文件:GameInfoWidget.java   
private void setMaxJumps(int amount) {
  jumps.clear();
  for (int i = 0; i < amount; ++i) {
    Image image = new Image(new SpriteDrawable(new Sprite(assets.get(Assets.TEX_CLOUD, Texture.class))));
    image.setColor(1f, 1f, 1f, ALPHA);
    image.setScale(0.75f);
    add(image);
    jumps.add(image);
  }
}
项目:clouboy    文件:AbstractScreen.java   
protected Actor createPlayButton(TitleButtonListener l) {
  final Image button = new Image(new SpriteDrawable(new Sprite(assets.get(Assets.TEX_BUTTON_PLAY, Texture.class))));
  if (l == null) {
    button.addCaptureListener(new TitleButtonListener() {
      @Override
      protected void clicked() {
        game.setScreen(new IngameScreen(game));
      }
    });
  } else {
    button.addCaptureListener(l);
  }
  button.getColor().a = BUTTON_TRANSPARENCY;
  return button;
}
项目:Radix    文件:SceneTheme.java   
public void init() {
    this.labelFont = new BitmapFont();

    this.buttonBgTex = new Texture(Gdx.files.internal("textures/gui/guiButtonBackground.png"));
    this.buttonBgPressTex = new Texture(Gdx.files.internal("textures/gui/guiButtonBackground-pressed.png"));
    this.buttonBgDisabledTex = new Texture(Gdx.files.internal("textures/gui/guiButtonBackground-disabled.png"));

    SpriteDrawable buttonBgSprite = new SpriteDrawable(new Sprite(buttonBgTex));
    SpriteDrawable buttonBgPressSprite = new SpriteDrawable(new Sprite(buttonBgPressTex));
    SpriteDrawable buttonBgDisabledSprite =new SpriteDrawable(new Sprite(buttonBgDisabledTex));
    this.buttonStyle = new ImageTextButtonStyle(buttonBgSprite, buttonBgPressSprite, buttonBgDisabledSprite, labelFont);
}
项目:Opus-Prototype    文件:SamplerEditor.java   
private void onSelectionChange(AbstractSampler pSampler) {
    sampler = pSampler;
    applyToSettings(pSampler);
    applyToPreview(pSampler);
    applyToModifier(pSampler);

    SpriteDrawable spriteDrawable = Styles.SAMPLER_ICON.get(pSampler.getClass());
    if (spriteDrawable != null) {
        samplerIcon.setDrawable(spriteDrawable);
    }
    scaleTextField.setText(pSampler.getConfig().scale + "");
    seedModTextField.setText(pSampler.getConfig().worldSeedModifier + "");
    updateIntervalLabel(sampler);
    pack();
}
项目:Opus-Prototype    文件:ProjectWindow.java   
public SamplerNode(Class aClass, Actor actor, final String id, TreeExpansionListener listener) {
    super(actor);
    this.id = id;
    this.aClass = aClass;
    this.listener = listener;
    nodeId = aClass.getCanonicalName() + id;
    SpriteDrawable spriteDrawable = Styles.SAMPLER_ICON.get(aClass);
    if (spriteDrawable != null) {
        setIcon(spriteDrawable);
    }
}
项目:Opus-Prototype    文件:ColorInterpreterItemForm.java   
private void fillImage(Image image, Color color) {
    Pixmap pixmap = new Pixmap(30, 30, Pixmap.Format.RGBA8888);
    for (int x = 0; x < pixmap.getWidth(); x++) {
        for (int y = 0; y < pixmap.getHeight(); y++) {
            pixmap.drawPixel(x, y, Color.argb8888(color.r, color.g, color.b, color.a));
        }
    }
    image.setDrawable(new SpriteDrawable(new Sprite(new Texture(pixmap))));
}
项目:MathMemory    文件:ReplayButton.java   
public ReplayButton() {
    super(new SpriteDrawable());
    this.clearChildren();
    this.getStyle().up = new SpriteDrawable(new Sprite(Assets.replay_icon_bg_up));
    this.getStyle().down = new SpriteDrawable(new Sprite(Assets.replay_icon_bg_down));
    this.add(new Image(Assets.replay_icon));
}
项目:MathMemory    文件:SoundButton.java   
public SoundButton() {
        super(new SpriteDrawable());
        this.clearChildren();
//      this.getStyle().up = new SpriteDrawable(new Sprite(Assets.music_icon_bg_up));
//      this.getStyle().down = new SpriteDrawable(new Sprite(Assets.music_icon_bg_down));
        this.storage = new Storage();
        musicOnIcon = new Image(Assets.music_on);
        musicOffIcon = new Image(Assets.music_off);
        checkSoundStatus();
    }
项目:MathMemory    文件:PauseButton.java   
public PauseButton() {
    super(new SpriteDrawable());
    this.clearChildren();
    this.getStyle().up = new SpriteDrawable(new Sprite(Assets.pause_icon_bg_up));
    this.getStyle().down = new SpriteDrawable(new Sprite(Assets.pause_icon_bg_down));

    pauseIcon = new Image(Assets.pause_icon);
    playIcon = new Image(Assets.play_icon);
    this.add(pauseIcon);
}
项目:MathMemory    文件:MenuButton.java   
public MenuButton() {
    super(new SpriteDrawable());
    this.clearChildren();
    this.getStyle().up = new SpriteDrawable(new Sprite(Assets.menu_icon_bg_up));
    this.getStyle().down = new SpriteDrawable(new Sprite(Assets.menu_icon_bg_down));
    this.add(new Image(Assets.menu_icon));
}
项目:Alien-Ark    文件:ShipProgressBar.java   
public ShipProgressBar(ProgressType progressType) {

        this.progressType = progressType;
        TextureAtlas.AtlasRegion bgTextureRegion = App.TEXTURES.findRegion("FuelShieldBackground");
        Sprite bgSprite = new Sprite(bgTextureRegion);

        Label label = new Label(progressType.name(), Styles.LABEL_PROGRESS_TYPE);
        progressTable = new ProgressTable(progressType);
        valueLabel = new Label("0", Styles.LABEL_HUD_NUMBERS);

        if (progressType == ProgressType.SHIELD) {
            bgSprite.flip(true, false);
            right().bottom();
            add(valueLabel).width(100);
            add(progressTable).right().width(205).padLeft(5).padRight(5);
            add(label).right().width(76).fill().padLeft(7);
        } else {
            left().bottom();
            add(label).left().width(73).fill().padLeft(10);
            add(progressTable).width(205).padLeft(5).padRight(5);
            add(valueLabel).width(100).padLeft(5);
        }
        setBackground(new SpriteDrawable(bgSprite));
        setWidth(bgTextureRegion.getRegionWidth());
        setHeight(bgTextureRegion.getRegionHeight());

        pack();
        applyPosition();
    }
项目:Topicos2015-2    文件:Explosion.java   
/**
 * Calcula o tempo acumulado e realiza a troca do estado da explosão
 *
 * @param delta
 */
public void update(float delta) {
    time += delta;
    if (time >= animationSpeed) {
        time = 0;
        state++;
        Texture texture = textures.get(state);
        actor.setDrawable(new SpriteDrawable(new Sprite(texture)));
    }
}
项目:libgdxcn    文件:Skin.java   
/** Returns a copy of the specified drawable. */
public Drawable newDrawable (Drawable drawable) {
    if (drawable instanceof TextureRegionDrawable) return new TextureRegionDrawable((TextureRegionDrawable)drawable);
    if (drawable instanceof NinePatchDrawable) return new NinePatchDrawable((NinePatchDrawable)drawable);
    if (drawable instanceof SpriteDrawable) return new SpriteDrawable((SpriteDrawable)drawable);
    throw new GdxRuntimeException("Unable to copy, unknown drawable type: " + drawable.getClass());
}
项目:gdx-skineditor    文件:Skin.java   
/** Returns a copy of the specified drawable. */
public Drawable newDrawable(Drawable drawable) {
    if (drawable instanceof TextureRegionDrawable)
        return new TextureRegionDrawable((TextureRegionDrawable) drawable);
    if (drawable instanceof NinePatchDrawable)
        return new NinePatchDrawable((NinePatchDrawable) drawable);
    if (drawable instanceof SpriteDrawable)
        return new SpriteDrawable((SpriteDrawable) drawable);
    throw new GdxRuntimeException("Unable to copy, unknown drawable type: " + drawable.getClass());
}
项目:OverdriveGDX    文件:ShipRoomDecorsActor.java   
/**
 * Adds a decoration at a rectangle encompassing a room's coordinates.
 *
 * TODO: Maybe allow non-rectangular rooms with ScissorsStack clipping.
 */
public void addDecor( ImageSpec imageSpec, ShipCoordinate[] coords ) {
    if ( imageSpec == null ) return;

    Rectangle decorBounds = null;
    for ( ShipCoordinate coord : coords ) {
        if ( coord.v != 0 ) continue;

        Rectangle tmpRect = new Rectangle( calcTileX( coord ), calcTileY( coord ), tileSize, tileSize );
        if ( decorBounds == null ) {
            decorBounds = tmpRect;
        } else {
            decorBounds.merge( tmpRect );
        }
    }
    if ( decorBounds == null ) return;

    if ( !atlasPaths.contains( imageSpec.getAtlasPath(), false ) ) {
        assetManager.load( imageSpec.getAtlasPath(), TextureAtlas.class );
        assetManager.finishLoading();
        atlasPaths.add( imageSpec.getAtlasPath() );
    }
    TextureAtlas decorAtlas = assetManager.get( imageSpec.getAtlasPath(), TextureAtlas.class );

    Sprite decorSprite = decorAtlas.createSprite( imageSpec.getRegionName() );
    SpriteDrawable decorDrawable = new SpriteDrawable( decorSprite );
    Image decorImage = new Image( decorDrawable );
    decorImage.setBounds( decorBounds.x, decorBounds.y, decorBounds.width, decorBounds.height );
    this.addActor( decorImage );

    // These are different floats which can cause gaps when mixed.
    // (x * size + size) != ((x+1) * size)
}
项目:ead    文件:EditorEmptyRendererProcessor.java   
public EditorEmptyRendererProcessor(Controller controller) {
    super(controller.getEngine().getGameLoop(), controller
            .getEditorGameAssets());
    this.engine = controller.getEngine();
    TextureRegionDrawable blank = (TextureRegionDrawable) controller
            .getApplicationAssets().getSkin().getDrawable("blank");
    Sprite sprite = new Sprite(blank.getRegion());
    sprite.setColor(INTERACTIVE_ZONE_COLOR);
    drawable = new SpriteDrawable(sprite);

    sprite = new Sprite(blank.getRegion());
    sprite.setColor(INTERACTIVE_ZONE_COLOR);
    sprite.setAlpha(0.25f);
    extendedDrawable = new SpriteDrawable(sprite);
}
项目:spezi-gdx    文件:Assets.java   
public static <T extends Image> T correctOrigin(T image) {
    image.setOrigin(image.getWidth() / 2, image.getHeight() / 2);
    if (image.getDrawable().getClass() == SpriteDrawable.class) {

        Sprite sprite = ((SpriteDrawable) image.getDrawable()).getSprite();
        sprite.setOrigin(sprite.getWidth() / 2, sprite.getHeight() / 2);

    }
    return image;
}
项目:androidsvgdrawable-plugin    文件:CardDeckApplication.java   
private void initializeAssets() {
    skin = manager.get("skin.json", Skin.class);
    atlas = manager.get("skin.atlas", TextureAtlas.class);

    // layout
    Table table = new Table();
    table.pad(10);
    table.defaults().space(10);
    table.setFillParent(true);

    // header
    table.row();
    table.add(new Label("LibGDX Card Deck", skin, "cantarell")).colspan(RANKS.length);

    // deck
    for (String suit : SUITS) {
        table.row();
        for (String rank : RANKS) {
            table.add(
                    new Image(
                            new SpriteDrawable(atlas.createSprite(String.format("card1_suit_%s_rank_%s", suit, rank))),
                            Scaling.fit));
        }
    }

    stage.addActor(table);
}
项目:ingress-indonesia-dev    文件:Skin.java   
public Drawable newDrawable(String paramString)
{
  Drawable localDrawable = getDrawable(paramString);
  if ((localDrawable instanceof TextureRegionDrawable))
    return new TextureRegionDrawable((TextureRegionDrawable)localDrawable);
  if ((localDrawable instanceof NinePatchDrawable))
    return new NinePatchDrawable((NinePatchDrawable)localDrawable);
  if ((localDrawable instanceof SpriteDrawable))
    return new SpriteDrawable((SpriteDrawable)localDrawable);
  throw new GdxRuntimeException("Unable to copy, unknown drawable type: " + localDrawable.getClass());
}