summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/rustanddust/ui/Patch.java
blob: f07c44d6a5819f1f89ced63778f1a4161d0ce08a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package ch.asynk.rustanddust.ui;

import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.NinePatch;

public class Patch extends Widget
{
    private NinePatch patch;

    public Patch(NinePatch patch)
    {
        super();
        this.patch = patch;
        setPosition(0, 0, patch.getTotalWidth(), patch.getTotalHeight());
    }

    @Override
    public void dispose()
    {
    }

    @Override
    public void draw(Batch batch)
    {
        if (!visible) return;
        patch.draw(batch, rect.x, rect.y, rect.width, rect.height);
    }

    public void setBtnRight(Bg btn)
    {
        btn.setPosition((rect.x + rect.width - (btn.getWidth() * 0.666f)), (rect.y -  (btn.getHeight() * 0.333f)));
    }

    public void setBtnLeft(Bg btn)
    {
        btn.setPosition((rect.x - (btn.getWidth() * 0.333f)), (rect.y -  (btn.getHeight() * 0.333f)));
    }
}