@Override public void set(byte index, Inventory inventory) { SlotElement slot = m_slots[index]; Entity item = inventory.item(index); ItemComponent itemComponent = itemMapper.get(item); m_slots[index].itemCountLabel.setText(Integer.toString(itemComponent.stackSize)); TextureRegion region; SpriteComponent spriteComponent = spriteMapper.get(item); if (blockMapper.get(item) != null) { // hack region = m_client.m_world.m_tileRenderer.m_tilesAtlas.findRegion( spriteComponent.textureName.concat("-00")); } else { region = m_client.m_world.m_atlas.findRegion(spriteComponent.textureName); } Image slotImage = slot.itemImage; // //m_blockAtlas.findRegion("stone")); slotImage.setDrawable(new TextureRegionDrawable(region)); slotImage.setSize(region.getRegionWidth(), region.getRegionHeight()); slotImage.setScaling(Scaling.fit); setHotbarSlotVisible(index, true); // do not exceed the max size/resort to horrible upscaling. prefer native size of each inventory // sprite. // .maxSize(region.getRegionWidth(), region.getRegionHeight()).expand().center(); }
private void init(String text, Image image, MenuItemStyle style) { this.style = style; this.image = image; setSkin(VisUI.getSkin()); Sizes sizes = getSkin().get(Sizes.class); defaults().space(3); if (image != null) image.setScaling(Scaling.fit); add(image).size(sizes.menuItemIconSize); label = new Label(text, new LabelStyle(style.font, style.fontColor)); label.setAlignment(Align.left); add(label).expand().fill(); add(shortcutLabel = new VisLabel("", "menuitem-shortcut")).padLeft(10).right(); shortcutLabelColor = shortcutLabel.getStyle().fontColor; subMenuIconCell = add(subMenuImage = new Image(style.subMenu)) .padLeft(3) .padRight(3) .size(style.subMenu.getMinWidth(), style.subMenu.getMinHeight()); subMenuIconCell.setActor(null); addListener( new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { // makes submenu item not clickable if (subMenu != null) event.stop(); } }); addListener( new InputListener() { @Override public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) { if (subMenu == null || isDisabled()) { // hides last visible submenu (if any) PopupMenu parent = (PopupMenu) getParent(); parent.setSubMenu(null); } else { Stage stage = getStage(); Vector2 pos = localToStageCoordinates(new Vector2(0, 0)); subMenu.setPosition( pos.x + getWidth() - 1, pos.y - subMenu.getHeight() + getHeight()); if (subMenu.getY() < 0) { subMenu.setY(subMenu.getY() + subMenu.getHeight() - getHeight()); } stage.addActor(subMenu); PopupMenu parent = (PopupMenu) getParent(); parent.setSubMenu(subMenu); } } }); }
public FinalDialogueScreen(final ButtonGame game) { this.game = game; stage = new Stage(new ScreenViewport()); dialogueLabel = new Label("", Resources.Skin()); dialogueLabel.setWrap(true); dialogueLabel.setColor(Color.CYAN); leftPerson = new Image(new Texture(Gdx.files.internal("graphics/CaptainCalamari.png"))); leftPerson.setVisible(false); rightPerson = new Image(new Texture(Gdx.files.internal("graphics/JimmyTwoButton.png"))); leftPerson.setScaling(Scaling.none); rightPerson.setScaling(Scaling.none); stage.addListener( new InputListener() { @Override public boolean touchDown( InputEvent event, float screenX, float screenY, int pointer, int button) { if (count < maxCount) { count = advanceDialogue(count); } else { game.startLevel(Level.get(game, 10)); } return true; } }); Table table = new Table(); table.setFillParent(true); table.align(Align.top); table.add().height(50).colspan(3).center(); table.row(); table.add(leftPerson); table.add(); // .width(20); table.add(rightPerson); table.row(); table.add().colspan(3).height(50); table.row(); table.add(dialogueLabel).width(600).colspan(3).center(); if (Resources.DEBUG) { table.setDebug(true); } stage.addActor(table); }
private void fillGroup(Group group, Texture texture) { float advance = 32 + SPACING; for (int y = 0; y < NUM_SPRITES * advance; y += advance) for (int x = 0; x < NUM_SPRITES * advance; x += advance) { Image img = new Image(new TextureRegion(texture)); img.setAlign(Align.center); img.setScaling(Scaling.none); img.setBounds(x, y, 32, 32); img.setOrigin(16, 16); group.addActor(img); images.add(img); } }
@Override public void create() { texture = new Texture(Gdx.files.internal("data/badlogicsmall.jpg")); texture.setFilter(TextureFilter.Linear, TextureFilter.Linear); font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false); stage = new Stage(); float loc = (NUM_SPRITES * (32 + SPACING) - SPACING) / 2; for (int i = 0; i < NUM_GROUPS; i++) { Group group = new Group(); group.setX((float) Math.random() * (stage.getWidth() - NUM_SPRITES * (32 + SPACING))); group.setY((float) Math.random() * (stage.getHeight() - NUM_SPRITES * (32 + SPACING))); group.setOrigin(loc, loc); fillGroup(group, texture); stage.addActor(group); } uiTexture = new Texture(Gdx.files.internal("data/ui.png")); uiTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); ui = new Stage(); Image blend = new Image(new TextureRegion(uiTexture, 0, 0, 64, 32)); blend.setAlign(Align.center); blend.setScaling(Scaling.none); blend.addListener( new InputListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { if (stage.getSpriteBatch().isBlendingEnabled()) stage.getSpriteBatch().disableBlending(); else stage.getSpriteBatch().enableBlending(); return true; } }); blend.setY(ui.getHeight() - 64); Image rotate = new Image(new TextureRegion(uiTexture, 64, 0, 64, 32)); rotate.setAlign(Align.center); rotate.setScaling(Scaling.none); rotate.addListener( new InputListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { rotateSprites = !rotateSprites; return true; } }); rotate.setPosition(64, blend.getY()); Image scale = new Image(new TextureRegion(uiTexture, 64, 32, 64, 32)); scale.setAlign(Align.center); scale.setScaling(Scaling.none); scale.addListener( new InputListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { scaleSprites = !scaleSprites; return true; } }); scale.setPosition(128, blend.getY()); ui.addActor(blend); ui.addActor(rotate); ui.addActor(scale); fps = new Label("fps: 0", new Label.LabelStyle(font, Color.WHITE)); fps.setPosition(10, 30); fps.setColor(0, 1, 0, 1); ui.addActor(fps); renderer = new ShapeRenderer(); Gdx.input.setInputProcessor(this); }
// constructor -------------------------------------------------------------------------- public ScoreBoardScreen(EndMissionReport missionData) { super(); // table setup // ******************************************************************************************************* int score = 0; boolean success = missionData.isSuccess(); // -- title ******************************************************* final Label title = new Label(success ? "Success" : "Failure", menuSkin, "title"); table.add(title).padTop(50).padBottom(40).padLeft(10).padRight(10).center().colspan(2); // -- team summary ************************************************ table.row().padBottom(10); final Label teamHeader = new Label("Team", menuSkin, "subTitle"); table.add(teamHeader).padLeft(20).spaceRight(40).left(); HorizontalGroup teammates = new HorizontalGroup(); teammates.space(10); int index = 0; for (int i = 0; i < missionData.safeMates.size; i++) { Image image = new Image(menuSkin.getDrawable(missionData.safeMates.get(i).getItemRegionName(false))); teammates.addActorAt(index, image); index++; } for (int i = 0; i < missionData.lostMates.size; i++) { Image image = new Image(menuSkin.getDrawable(missionData.lostMates.get(i).getItemRegionName(true))); teammates.addActorAt(index, image); score += LOST_MATE_SCORE; index++; } teammates.pack(); table.add(teammates).padRight(20).center(); // -- substance summary ************************************************ table.row().padBottom(10); final Label harvestHeader = new Label("Harvest", menuSkin, "subTitle"); table.add(harvestHeader).padLeft(20).spaceRight(40).left(); HorizontalGroup substances = new HorizontalGroup(); substances.space(10); if (missionData.collectedSubstance > 0) { Image banner = new Image(menuSkin.getDrawable("banner" + missionData.collectedSubstance)); banner.setScaling(Scaling.none); banner.setAlign(Align.bottomRight); Stack stack = new Stack(); stack.addActor(new Image(menuSkin.getDrawable("item_substance"))); stack.addActor(banner); score += SUBSTANCE_SCORE * missionData.collectedSubstance; substances.addActor(stack); } if (missionData.targetSubstance - missionData.collectedSubstance > 0) { Image banner = new Image( menuSkin.getDrawable( "banner" + (missionData.targetSubstance - missionData.collectedSubstance))); banner.setScaling(Scaling.none); banner.setAlign(Align.bottomRight); Stack stack = new Stack(); stack.addActor(new Image(menuSkin.getDrawable("item_outSubstance"))); stack.addActor(banner); substances.addActor(stack); } table.add(substances).padRight(20).center(); // consumption summary ************************************************ table.row().padBottom(10); final Label usedHeader = new Label("Used", menuSkin, "subTitle"); table.add(usedHeader).padLeft(20).spaceRight(40).left(); HorizontalGroup collectibles = new HorizontalGroup(); collectibles.space(10); score += USED_SUPPLY_SCORE * missionData.usedSupply; int itemCount = missionData.usedSupply / 10; // supplies ******* for (int i = 0; i < itemCount; i++) { Image banner = new Image(menuSkin.getDrawable("banner10")); banner.setScaling(Scaling.none); banner.setAlign(Align.bottomRight); Stack stack = new Stack(); stack.addActor(new Image(menuSkin.getDrawable("item_supply"))); stack.addActor(banner); collectibles.addActor(stack); } int extraItems = missionData.usedSupply % 10; if (extraItems > 0) { Image banner = new Image(menuSkin.getDrawable("banner" + extraItems)); banner.setScaling(Scaling.none); banner.setAlign(Align.bottomRight); Stack stack = new Stack(); stack.addActor(new Image(menuSkin.getDrawable("item_supply"))); stack.addActor(banner); collectibles.addActor(stack); } // materials ******* score += USED_MATERIAL_SCORE * missionData.usedMaterial; itemCount = missionData.usedMaterial / 10; for (int i = 0; i < itemCount; i++) { Image banner = new Image(menuSkin.getDrawable("banner10")); banner.setScaling(Scaling.none); banner.setAlign(Align.bottomRight); Stack stack = new Stack(); stack.addActor(new Image(menuSkin.getDrawable("item_material"))); stack.addActor(banner); collectibles.addActor(stack); } extraItems = missionData.usedMaterial % 10; if (extraItems > 0) { Image banner = new Image(menuSkin.getDrawable("banner" + extraItems)); banner.setScaling(Scaling.none); banner.setAlign(Align.bottomRight); Stack stack = new Stack(); stack.addActor(new Image(menuSkin.getDrawable("item_material"))); stack.addActor(banner); collectibles.addActor(stack); } collectibles.pack(); // -- time bonus summary ************************************************ table.add(collectibles).padRight(20).center(); table.row().padBottom(10); final Label timeHeader = new Label("Time Bonus", menuSkin, "subTitle"); table.add(timeHeader).padLeft(20).spaceRight(40).left(); float timeBonus; if (missionData.missionTimeLeft <= 0f) { timeBonus = TIMEUP_SCOREMULT; } else if (missionData.missionTimeLeft <= 60f) { timeBonus = ONTIME_SCOREMULT; } else if (missionData.missionTimeLeft <= 120f) { timeBonus = GOODTIME_SCOREMULT; } else timeBonus = GREATTIME_SCOREMULT; table.add(new Label("x" + timeBonus, menuSkin, "title")).padRight(10).center(); // -- score summary ***************************************************** table.row().padTop(10).padBottom(50); final Label scoreHeader = new Label("Score", menuSkin, "subTitle"); table.add(scoreHeader).padLeft(20).spaceRight(40).left(); if (score > 0) score = Math.round(timeBonus * (float) score); float maxScore = GREATTIME_SCOREMULT * Math.min(missionData.targetSubstance, missionData.targetSubstance + 2) * SUBSTANCE_SCORE; int star_count = Math.max(1, MathUtils.floor(4f * score / maxScore)); star_count = (!success || missionData.lostMates.size > 0 ? 1 : star_count); HorizontalGroup scoreStars = new HorizontalGroup(); scoreStars.space(5); for (int i = 0; i < star_count; i++) { Image image = new Image(menuSkin.getDrawable(success ? "goldStar" : "silverStar")); scoreStars.addActorAt(i, image); } table.add(scoreStars).padRight(10).center(); }
@Override public void create() { skin = new Skin(Gdx.files.internal(SKIN)); EditorLogger.setDebug(); EditorLogger.debug("CREATE"); Ctx.project = new Project(); Ctx.msg = new Message(skin); Ctx.assetManager = new EditorAssetManager(); scnEditor = new ScnEditor(skin); skin.getFont("default-font").getData().markupEnabled = true; /** * STAGE SETUP ** */ stage = new Stage(new ScreenViewport()); Gdx.input.setInputProcessor(stage); // RIGHT PANEL ScenePanel scenePanel = new ScenePanel(skin); ActorPanel actorPanel = new ActorPanel(skin); Table rightPanel = new Table(); rightPanel.top().left(); // rightPanel.add(scenePanel).expand().fill(); // rightPanel.row(); rightPanel.add(actorPanel).expand().fill(); SplitPane splitPaneRight = new SplitPane(scnEditor, rightPanel, false, skin); // LEFT PANEL ProjectPanel projectPanel = new ProjectPanel(skin); // AssetPanel assetPanel = new AssetPanel(skin); Image img = new Image(Ctx.assetManager.getIcon("title")); img.setScaling(Scaling.none); img.setAlign(Align.left); Table leftPanel = new Table(); leftPanel.top().left().padLeft(10); leftPanel.add(img).expand().fill().padBottom(20).padTop(20).padLeft(20); leftPanel.row(); leftPanel.add(new ProjectToolbar(skin)).expandX().fill(); leftPanel.row(); leftPanel.add(projectPanel).expand().fill(); leftPanel.row(); leftPanel.add(scenePanel).expand().fill(); SplitPane splitPaneLeft = new SplitPane(leftPanel, splitPaneRight, false, skin); splitPaneLeft.setFillParent(true); splitPaneLeft.setSplitAmount(0.3f); stage.addActor(splitPaneLeft); // LOAD LAST OPEN PROJECT String lastProject = Ctx.project.getEditorConfig().getProperty(Project.LAST_PROJECT_PROP, ""); if (!lastProject.isEmpty() && new File(lastProject).exists()) { try { EditorLogger.debug("Loading last project: " + lastProject); Ctx.project.loadProject(new File(lastProject)); } catch (Exception e) { EditorLogger.debug("Error loading last project: " + e.getMessage()); Ctx.project.closeProject(); e.printStackTrace(); } } stage.setScrollFocus(scnEditor.getScnWidget()); stage.setKeyboardFocus(scnEditor.getScnWidget()); }
@Override public void show() { isMuted = game.prefs.getBoolean("settingsMute"); doVibrate = game.prefs.getBoolean("settingsVibrate"); bigFont = game.manager.get("big_font.ttf", BitmapFont.class); mediumFont = game.manager.get("medium_font.ttf", BitmapFont.class); logoTexture = game.manager.get("logo.png", Texture.class); logoTextureHorizontal = game.manager.get("logo_horizontal.png", Texture.class); levelsTexture = game.manager.get("levels_icon.png", Texture.class); levelsTexturePressed = game.manager.get("levels_icon_pressed.png", Texture.class); randomTexture = game.manager.get("random_icon.png", Texture.class); randomTexturePressed = game.manager.get("random_icon_pressed.png", Texture.class); shopTexture = game.manager.get("shop_icon.png", Texture.class); shopTexturePressed = game.manager.get("shop_icon_pressed.png", Texture.class); settingsTexture = game.manager.get("settings_icon.png", Texture.class); settingsTexturePressed = game.manager.get("settings_icon_pressed.png", Texture.class); clickSound = game.manager.get("click.mp3", Sound.class); logoTexture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); logoTextureHorizontal.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); levelsTexture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); levelsTexturePressed.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); randomTexture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); randomTexturePressed.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); shopTexture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); shopTexturePressed.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); settingsTexture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); settingsTexturePressed.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); levelsButtonStyle = new ImageButton.ImageButtonStyle(); levelsButtonStyle.imageUp = new TextureRegionDrawable(new TextureRegion(levelsTexture)); levelsButtonStyle.imageDown = new TextureRegionDrawable(new TextureRegion(levelsTexturePressed)); randomButtonStyle = new ImageButton.ImageButtonStyle(); randomButtonStyle.imageUp = new TextureRegionDrawable(new TextureRegion(randomTexture)); randomButtonStyle.imageDown = new TextureRegionDrawable(new TextureRegion(randomTexturePressed)); shopButtonStyle = new ImageButton.ImageButtonStyle(); shopButtonStyle.imageUp = new TextureRegionDrawable(new TextureRegion(shopTexture)); shopButtonStyle.imageDown = new TextureRegionDrawable(new TextureRegion(shopTexturePressed)); settingsButtonStyle = new ImageButton.ImageButtonStyle(); settingsButtonStyle.imageUp = new TextureRegionDrawable(new TextureRegion(settingsTexture)); settingsButtonStyle.imageDown = new TextureRegionDrawable(new TextureRegion(settingsTexturePressed)); labelStyleBig = new Label.LabelStyle(); labelStyleBig.font = bigFont; labelStyleMedium = new Label.LabelStyle(); labelStyleMedium.font = mediumFont; stage = new Stage(new ScreenViewport()); stage.addListener( new InputListener() { @Override public boolean keyDown(InputEvent event, int keycode) { if (keycode == Input.Keys.BACK || keycode == Input.Keys.BACKSPACE) { GDXButtonDialog dialog = game.dialogs.newDialog(GDXButtonDialog.class); dialog.setTitle("Are you sure?"); dialog.setMessage("Are you sure you want to exit?"); dialog.setClickListener( new ButtonClickListener() { @Override public void click(int button) { if (button == 1) { Gdx.app.exit(); } } }); dialog.addButton("No"); dialog.addButton("Yes"); dialog.build().show(); } return true; } }); stage.setDebugAll(false); Gdx.input.setInputProcessor(stage); Gdx.input.setCatchBackKey(true); Image logoImage = new Image(logoTexture); Image logoImageHorizontal = new Image(logoTextureHorizontal); logoImage.setScaling(Scaling.fit); logoImageHorizontal.setScaling(Scaling.fit); ImageButton levelsButton = new ImageButton(levelsButtonStyle); levelsButton.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { if (!isMuted) { clickSound.play(); } if (doVibrate) { Gdx.input.vibrate(25); } game.setScreen(new LevelSelectScreen(game)); } }); Label levelsLabel = new Label("Levels", labelStyleMedium); ImageButton randomButton = new ImageButton(randomButtonStyle); randomButton.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { if (!isMuted) { clickSound.play(); } if (doVibrate) { Gdx.input.vibrate(25); } game.setScreen(new GameScreen(game, game.randomLevel())); } }); Label randomLabel = new Label("Random", labelStyleMedium); ImageButton shopButton = new ImageButton(shopButtonStyle); shopButton.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { if (!isMuted) { clickSound.play(); } if (doVibrate) { Gdx.input.vibrate(25); } game.setScreen(new ShopScreen(game)); } }); Label shopLabel = new Label("Shop", labelStyleMedium); ImageButton settingsButton = new ImageButton(settingsButtonStyle); settingsButton.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { if (!isMuted) { clickSound.play(); } if (doVibrate) { Gdx.input.vibrate(25); } game.setScreen(new SettingsScreen(game)); } }); Label settingsLabel = new Label("Settings", labelStyleMedium); table = new Table(); table.setFillParent(true); table .add(logoImage) .colspan(2) .size(game.sizeModifier * 950) .padTop(game.sizeModifier * -75f) .padBottom(game.sizeModifier * -160f); table.row(); table.add(levelsButton).size(game.sizeModifier * 250).padRight(game.sizeModifier * -30); table.add(randomButton).size(game.sizeModifier * 250).padLeft(game.sizeModifier * -30); table.row(); table .add(levelsLabel) .padBottom(game.sizeModifier * 120) .padRight(game.sizeModifier * -30) .top(); table .add(randomLabel) .padBottom(game.sizeModifier * 120) .padLeft(game.sizeModifier * -30) .top(); table.row(); table.add(shopButton).size(game.sizeModifier * 250).padRight(game.sizeModifier * -30); table.add(settingsButton).size(game.sizeModifier * 260).padLeft(game.sizeModifier * -30); table.row(); table.add(shopLabel).expand().padRight(game.sizeModifier * -30).top(); table.add(settingsLabel).expand().padLeft(game.sizeModifier * -30).top(); stage.addActor(table); }
/* public static final String SOUND_ENABLED_BOOL = "SOUND_ENABLED_BOOL"; public static final String ENCOURAGE_TEXT_ENABLED_BOOL = "SOUND_ENABLED_BOOL"; public static final String EFFECTS_ENABLED_BOOL = "EFFECTS_ENABLED_BOOL"; public static final String COINS_INT = "COINS_INT"; public static final String HIGH_SCORE_INT = "HIGH_SCORE_INT"; public static final String CURRENT_COLOR = "CURRENT_COLOR"; public static final String CURRENT_HAT = "CURRENT_HAT"; public static final String CURRENT_MOUSTACHE = "CURRENT_MOUSTACHE"; public static final int COLOR_PRICE = 20; public static final int BUTTON_Y = Gdx.graphics.getHeight() / 11; public static final int FIRST_BUTTON_X = (int) (Gdx.graphics.getWidth() / 9.318f); public static final int BUTTON_WIDTH = (int) ((Gdx.graphics.getWidth() - (Gdx.graphics.getWidth() / 3.727f)) / 2); // public static final String TRAILS_BOUGHT = "TRAILS_BOUGHT"; public static final String TOTAL_JUMPS = "TOTAL_JUMPS"; public static final String TOTAL_DEATHS = "TOTAL_DEATHS"; public static final ArrayList<String> hats = new ArrayList<String>(Arrays.asList("h0", "h1", "h10", "h11", "h12", "h13", "h14", "h15", "h16", "h17", "h18", "h19", "h2", "h20", "h21", "h22", "h23", "h24", "h25", "h26", "h27", "h28", "h3", "h4", "h5", "h6", "h7", "h8", "h9")); public static final ArrayList<String> moustaches = new ArrayList<String>(Arrays.asList("m0", "m1", "m2", "m3", "m4")); public static final int height = Gdx.graphics.getHeight(); public static final int width = Gdx.graphics.getWidth(); private static final String HATS_BOUGHT = "HATS_BOUGHT"; private static final String COLORS_BOUGHT = "COLORS_BOUGHT"; private static final String MOUSTACHES_BOUGHT = "MOUSTACHES_BOUGHT"; private static final Random rand = new Random(); private static final int playerYpos = Math.round(Gdx.graphics.getHeight() - ((Gdx.graphics.getWidth() / 10f) * 6)); private static final float speedFactor = Gdx.graphics.getHeight() / 1210f; private static BitmapFont font = new BitmapFont(Gdx.files.internal("font.fnt")); private static TextureAtlas sprites = new TextureAtlas(Gdx.files.internal("sprites.txt")); private static int playerWidth = (int) (Gdx.graphics.getWidth() / 10f), tileWidth = (int) (Gdx.graphics.getWidth() / 10.25f); private final Texture coin = new Texture(Gdx.files.internal("coin.png")); public static int getPlayerYpos() { return playerYpos; } public static TextureAtlas getAtlas() { return sprites; } private static Color colorFromString(String color, float alpha) { final String[] floats = color.split(","); return new Color(Float.parseFloat(floats[0]), Float.parseFloat(floats[1]), Float.parseFloat(floats[2]), alpha); } */ private static Image getColorSprite(int w, final int id, String color) { // final Pixmap pixmap = new Pixmap(w, w, Pixmap.Format.RGBA8888); // Pixmap.setBlending(Pixmap.Blending.None); // pixmap.setColor(0xffffffff); // w /= 2; // pixmap.fillCircle(w, w, w); // pixmap.setColor(Utility.colorFromString(color)); // int r = (int) (w * 0.98f); // pixmap.fillCircle(w, w, r); // // final Texture texture = new Texture(pixmap); // pixmap.dispose(); // boolean bought = Utility.isItemBought(color); // // final BitmapFont font = Utility.getFont(); // font.setColor(textColor); // font.setScale(0.25f); // // final float textWidth = font.getBounds("30").width; // final float textHeight = font.getLineHeight(); // final int viewWidth = Math.round(textWidth + (textHeight / 2)); // final int titleHeight = Math.round(font.getLineHeight() + (textHeight / 2)); // final int distanceFromEdge = Math.round((viewWidth + titleHeight) * tagRatio); // int textYpos = 0; // // Sprite text = null; // // if (!bought) { // clearScreen(); // final int pH = titleHeight; // final int pW = viewWidth + (2 * titleHeight); // textYpos = Math.round(pH * tagRatio); // Pixmap p = new Pixmap(pW, pH, Pixmap.Format.RGBA4444); // p.setColor(white); // p.fillTriangle(0, 0, pH, pH, pH, 0); // p.fillRectangle(pH, 0, pW - pH - pH, pH); // p.fillTriangle(pW - pH, pH, pW, 0, pW - pH, 0); // Texture t = new Texture(p); // batch.begin(); // batch.draw(t, 0, 0); // font.draw(batch, "30", (pW / 2) - (textWidth / 2), (titleHeight / 2) + (textHeight // / 3)); // batch.end(); // text = new Sprite(ScreenUtils.getFrameBufferTexture(0, 0, pW, pH)); // if (pW > sw) // text.setScale((float) sw / pW); // else // text.setScale(1); // // text.setOrigin(0, 0); // } // clearScreen(); // // // batch.begin(); // batch.draw(texture, 0, 0, sw, sw); // if (!bought) // batch.draw(text, sw - distanceFromEdge, 0 - textYpos, 0, 0, text.getWidth(), // text.getHeight(), text.getScaleX(), text.getScaleY(), 45); // batch.end(); Image image = new Image(ScreenUtils.getFrameBufferTexture(0, 0, 50, 50)); image.setScaling(Scaling.fit); image.setUserObject("item" + String.valueOf(id)); return image; }