use of com.bladecoder.engine.model.ActorRenderer in project bladecoder-adventure-engine by bladecoder.
the class InventoryUI method draw.
@Override
public void draw(Batch batch, float alpha) {
Inventory inventory = World.getInstance().getInventory();
if (!inventory.isVisible()) {
setVisible(false);
return;
}
if (style.background != null) {
style.background.draw(batch, getX(), getY(), getWidth(), getHeight());
}
// DRAW ITEMS
int capacity = cols * rows;
for (int i = 0; i < inventory.getNumItems() && i < capacity; i++) {
SpriteActor a = inventory.get(i);
ActorRenderer r = a.getRenderer();
float size = (tileSize - rowSpace) / (r.getHeight() > r.getWidth() ? r.getHeight() : r.getWidth());
float x = i % cols;
float y = (rows - 1) - i / cols;
if (style.itemBackground != null) {
style.itemBackground.draw(batch, getX() + x * tileSize + x * rowSpace + margin, getY() + y * tileSize + y * rowSpace + margin, tileSize, tileSize);
}
r.draw((SpriteBatch) batch, getX() + x * tileSize + x * rowSpace + tileSize / 2 + margin, getY() + (tileSize - r.getHeight() * size) / 2 + y * tileSize + y * rowSpace + margin, size, 0f, a.getTint());
}
super.draw(batch, alpha);
}
use of com.bladecoder.engine.model.ActorRenderer in project bladecoder-adventure-engine by bladecoder.
the class ScenePointer method draw.
public void draw(SpriteBatch batch, Viewport v) {
getInputUnproject(v, mousepos);
boolean multiTouch = Gdx.input.isPeripheralAvailable(Peripheral.MultitouchScreen);
// DRAW TARGET DESCRIPTION
if (desc != null && (!multiTouch || Gdx.input.isTouched())) {
float margin = DPIUtils.UI_SPACE;
float textX = mousepos.x - layout.width / 2;
float textY = mousepos.y + layout.height + DPIUtils.UI_SPACE + DPIUtils.getTouchMinSize();
if (textX < 0)
textX = 0;
RectangleRenderer.draw(batch, textX - margin, textY - layout.height - margin, layout.width + margin * 2, layout.height + margin * 2, Color.BLACK);
font.draw(batch, layout, textX, textY);
}
if (draggingActor == null) {
if (!multiTouch || currentIcon == leaveIcon) {
batch.draw(currentIcon, mousepos.x - currentIcon.getRegionWidth() / 2, mousepos.y - currentIcon.getRegionHeight() / 2, currentIcon.getRegionWidth() / 2, currentIcon.getRegionHeight() / 2, currentIcon.getRegionWidth(), currentIcon.getRegionHeight(), pointerScale, pointerScale, currentIcon == leaveIcon ? leaveRotation : 0);
}
} else {
float h = (draggingActor.getHeight() > draggingActor.getWidth() ? draggingActor.getHeight() : draggingActor.getWidth());
float size = DPIUtils.getTouchMinSize() / h * 1.8f;
ActorRenderer r = draggingActor.getRenderer();
r.draw(batch, mousepos.x, mousepos.y - draggingActor.getHeight() * size / 2, size, 0f, currentIcon != hotspotIcon ? tmpTint : draggingActor.getTint());
}
}
Aggregations