@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(); }
public LoadingStage() { initViewport(); // Get our textureatlas from the manager, then get assets TextureAtlas atlas = Game.GDXVars().getTextureAtlas(Paths.loadingPack); font = Game.GDXVars().getFont(Paths.defaultFont); // Create actors background = new Image(Game.GDXVars().getTexture(Paths.splashBackground)); background.setSize(getWidth(), getHeight()); loadingBar = new LoadingBar(atlas); loadingBar.setPosition(getWidth() / 2 - loadingBar.getWidth() / 2, loadingBar.getHeight() / 2f); // Add actors addActor(background); addActor(loadingBar); // Selection group selector = new AtlasSelector( Game.GDXVars().getTextureAtlas(Paths.charactersPack), Game.Save().characters); addActor(selector); selector.setPosition(getWidth() / 2f - selector.getWidth() / 2f, 130); progress = 0f; // Start the work startLoadingWork(); }
@Override public void update(double population) { float size = ((float) population / 10000) + 20; if (size < MIN_SIZE) size = MIN_SIZE; else if (size > MAX_SIZE) size = MAX_SIZE; settlementImage.setSize(size, size); }
@Override public void layout() { image.setPosition(0, 0); image.setSize(64, 64); txtName.setPosition(64, getPrefHeight() - txtName.getPrefHeight() - 5); txtName.setSize(txtName.getPrefWidth(), txtName.getPrefHeight()); txtSoul.setPosition(64, txtName.getY() - txtSoul.getPrefHeight() + 5); txtSoul.setSize(txtSoul.getPrefWidth(), txtSoul.getPrefHeight()); }
public SplashScreen(TestGame pGame) { game = pGame; tree = new Texture( Gdx.files.internal( "graphics/tree.png")); // http://openclipart.org/detail/1936/tree-by-harmonic christmasTree = new TextureRegion(tree, 0, 0, 450, 730); ball = new Texture( Gdx.files.internal( "graphics/ball.png")); // http://openclipart.org/detail/170738/decorative-ball-by-merlin2525-170738 snow = new Texture( Gdx.files.internal( "graphics/snow.png")); // http://openclipart.org/detail/170738/decorative-ball-by-merlin2525-170738 font = new BitmapFont(Gdx.files.internal("ui/test.fnt"), false); stage = new Stage(); // our christmas tree Image ctree = new Image(christmasTree); ctree.setSize(296, 480); // scale the tree to the right size ctree.setPosition(-300, 0); ctree.addAction(moveTo(400 - 148, 0, 1f)); ctree.setZIndex(0); stage.addActor(ctree); Image ballImage = new Image(ball); ballImage.setPosition(400 - 148 + 60, 170); ballImage.setOrigin(32, 32); ballImage.setColor(1, 1, 1, 0); ballImage.addAction( sequence( delay(1), parallel(fadeIn(1), rotateBy(360, 1)), delay(2f), new Action() { // custom action to switch to the menu screen @Override public boolean act(float delta) { game.setScreen(new MenuScreen(game)); return false; } })); stage.addActor(ballImage); // create the snowflakes for (int i = 0; i < 10; i++) { spawnSnowflake(); } }
public void addToStage(Stage stage, int x, int y, int width, int height) { this.x = x; this.y = y; this.width = width; this.height = height; System.out.println("Drawn at " + x + " " + y + " Dimensions " + width + " " + height); Texture texture = new Texture(Gdx.files.internal("Fuego_Back.png")); frontImage = new Image(texture); frontImage.setSize(width, height); frontImage.setPosition(x, y); backImage.setPosition(x, y); backImage.setSize(Gdx.graphics.getWidth() / 2, Gdx.graphics.getWidth() / 2 * 4 / 3); backImage.addAction(Actions.scaleTo(0, 1)); stage.addActor(frontImage); stage.addActor(backImage); }
/** * Artifact that the user can buy after retiring and can then upgrade * * @param _amount Amount the artifact does * @param _cost Cost of artifact * @param _type Type of artifact * @param _game Game to put in */ public BaseArtifact(double _amount, int _cost, TYPE _type, GameRenderer _game) { originalAmount = _amount; type = _type; game = _game; cost = _cost; offering = false; currentAmount = 0; level = 0; picture = new Image(AssetLoader.textureAtlas.findRegion(getName())); picture.setSize(128, 128); amount = originalAmount; setDescription(); }
public HotbarInventoryView( Stage stage, Skin skin, Inventory hotbarInventory, Inventory inventory, DragAndDrop dragAndDrop, OreClient client) { m_skin = skin; m_inventory = inventory; m_client = client; m_stage = stage; m_hotbarInventory = hotbarInventory; // attach to the inventory model m_hotbarInventory.addListener(this); container = new Table(m_skin); container.setFillParent(true); container.top().left().setSize(800, 100); container.padLeft(10).padTop(10); container.defaults().space(4); stage.addActor(container); Image dragImage = new Image(); dragImage.setSize(32, 32); for (byte i = 0; i < Inventory.maxHotbarSlots; ++i) { Image slotImage = new Image(); SlotElement element = new SlotElement(); m_slots[i] = element; element.itemImage = slotImage; Table slotTable = new Table(m_skin); element.table = slotTable; slotTable.setTouchable(Touchable.enabled); slotTable.addListener(new SlotClickListener(this, i)); slotTable.addListener(new SlotInputListener(this, i)); slotTable.add(slotImage); slotTable.background("default-pane"); slotTable.row(); Label itemCount = new Label(null, m_skin); slotTable.add(itemCount).bottom().fill(); element.itemCountLabel = itemCount; // container.add(slotTable).size(50, 50); container.add(slotTable).fill().size(50, 50); setHotbarSlotVisible(i, false); dragAndDrop.addSource(new HotbarDragSource(slotTable, i, dragImage, this)); dragAndDrop.addTarget(new HotbarDragTarget(slotTable, i, this)); } m_tooltip = new Label(null, m_skin); stage.addActor(m_tooltip); }