Search in sources :

Example 6 with Inventory

use of com.bladecoder.engine.model.Inventory in project bladecoder-adventure-engine by bladecoder.

the class InventoryUI method getItemAt.

public SpriteActor getItemAt(float x, float y) {
    if (x < margin || y < margin || x >= getWidth() - margin || y >= getHeight() - margin)
        return null;
    Inventory inventory = World.getInstance().getInventory();
    int i = ((rows - 1) - ((int) (y - margin) / (tileSize + (int) rowSpace))) * cols + (int) (x - margin) / (tileSize + (int) rowSpace);
    if (i >= 0 && i < inventory.getNumItems()) {
        // inventory.getItem(i).getDesc());
        return inventory.get(i);
    }
    return null;
}
Also used : Inventory(com.bladecoder.engine.model.Inventory)

Aggregations

Inventory (com.bladecoder.engine.model.Inventory)6 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)2 ImageButton (com.badlogic.gdx.scenes.scene2d.ui.ImageButton)2 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)2 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)2 ActorRenderer (com.bladecoder.engine.model.ActorRenderer)1 InteractiveActor (com.bladecoder.engine.model.InteractiveActor)1 SpriteActor (com.bladecoder.engine.model.SpriteActor)1