Search in sources :

Example 6 with ActorRenderer

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);
}
Also used : SpriteActor(com.bladecoder.engine.model.SpriteActor) ActorRenderer(com.bladecoder.engine.model.ActorRenderer) Inventory(com.bladecoder.engine.model.Inventory)

Example 7 with ActorRenderer

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());
    }
}
Also used : ActorRenderer(com.bladecoder.engine.model.ActorRenderer)

Aggregations

ActorRenderer (com.bladecoder.engine.model.ActorRenderer)7 ImageRenderer (com.bladecoder.engine.model.ImageRenderer)5 AtlasRenderer (com.bladecoder.engine.model.AtlasRenderer)4 Sprite3DRenderer (com.bladecoder.engine.model.Sprite3DRenderer)4 SpineRenderer (com.bladecoder.engine.spine.SpineRenderer)4 SpriteActor (com.bladecoder.engine.model.SpriteActor)3 Vector2 (com.badlogic.gdx.math.Vector2)2 SpineAnimationDesc (com.bladecoder.engine.anim.SpineAnimationDesc)2 AnimationDesc (com.bladecoder.engine.anim.AnimationDesc)1 AtlasAnimationDesc (com.bladecoder.engine.anim.AtlasAnimationDesc)1 AnchorActor (com.bladecoder.engine.model.AnchorActor)1 AnimationRenderer (com.bladecoder.engine.model.AnimationRenderer)1 CharacterActor (com.bladecoder.engine.model.CharacterActor)1 InteractiveActor (com.bladecoder.engine.model.InteractiveActor)1 Inventory (com.bladecoder.engine.model.Inventory)1 ObstacleActor (com.bladecoder.engine.model.ObstacleActor)1 ParticleRenderer (com.bladecoder.engine.model.ParticleRenderer)1 TextRenderer (com.bladecoder.engine.model.TextRenderer)1 File (java.io.File)1 FilenameFilter (java.io.FilenameFilter)1