com.uwsoft.editor.renderer.systems.render.logic.NinePatchDrawableLogic Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of overlap2d-runtime-libgdx Show documentation
Show all versions of overlap2d-runtime-libgdx Show documentation
overlap2d-runtime-libgdx provides functionality to load, manipulate and render scenes generated by Overlap2D.
The newest version!
package com.uwsoft.editor.renderer.systems.render.logic;
import com.badlogic.ashley.core.ComponentMapper;
import com.badlogic.ashley.core.Entity;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.math.Matrix4;
import com.uwsoft.editor.renderer.components.*;
public class NinePatchDrawableLogic implements Drawable {
private ComponentMapper tintComponentComponentMapper;
private ComponentMapper transformMapper;
private ComponentMapper dimensionsMapper;
private ComponentMapper ninePatchMapper;
public NinePatchDrawableLogic() {
tintComponentComponentMapper = ComponentMapper.getFor(TintComponent.class);
transformMapper = ComponentMapper.getFor(TransformComponent.class);
dimensionsMapper = ComponentMapper.getFor(DimensionsComponent.class);
ninePatchMapper = ComponentMapper.getFor(NinePatchComponent.class);
}
@Override
public void draw(Batch batch, Entity entity) {
TintComponent tintComponent = tintComponentComponentMapper.get(entity);
TransformComponent entityTransformComponent = transformMapper.get(entity);
DimensionsComponent entityDimensionsComponent = dimensionsMapper.get(entity);
NinePatchComponent entityNinePatchComponent = ninePatchMapper.get(entity);
batch.setColor(tintComponent.color);
entityNinePatchComponent.ninePatch.draw(batch, entityTransformComponent.x, entityTransformComponent.y, entityDimensionsComponent.width, entityDimensionsComponent.height);
}
}