@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 dropStar(Image img) { stars--; img.setDrawable(new TextureRegionDrawable(Assets.instance.gameElements.starOff)); star.setPosition(img.getX() - 45, img.getY() - 50); star.addAction( Actions.sequence( Actions.scaleTo(0.3f, 0.3f), Actions.alpha(1f), Actions.parallel( Actions.rotateBy(210f, 0.9f), Actions.scaleTo(0.8f, 0.8f, 0.9f), Actions.moveTo(star.getX() - 45f, star.getY() - 210f, 1.2f), Actions.alpha(0f, 0.9f, Interpolation.circleIn)))); }
@Override public void render(float delta) { Gdx.gl.glClearColor(1f, 1f, 1f, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); Texture newTexture = SwapTextureFromArray(texturesList, actualImgIndex, beginTime, 3); imgActor.setDrawable(new SpriteDrawable(new Sprite(newTexture))); stage.act(); stage.draw(); if (Gdx.input.isKeyPressed(Input.Keys.ESCAPE)) { game.setScreen(game.mainScene); } }
public City(Image image) { allowedResources.add(Resource.WATER); allowedResources.add(Resource.GRAIN); allowedResources.add(Resource.STONE); allowedResources.add(Resource.WOOD); allowedResources.add(Resource.FRUIT); allowedResources.add(Resource.FISH); allowedResources.add(Resource.IRON); allowedResources.add(Resource.VENISON); allowedResources.add(Resource.CRAB); allowedResources.add(Resource.GOLD); allowedResources.add(Resource.PAPER); allowedResources.add(Resource.HIGH_FRUCTOSE_CORN_SYRUP); settlementImage = image; settlementImage.setDrawable(new TextureRegionDrawable(new TextureRegion(diamond))); }