use of com.badlogic.gdx.scenes.scene2d.utils.TransformDrawable in project libgdx by libgdx.
the class Image method draw.
public void draw(Batch batch, float parentAlpha) {
validate();
Color color = getColor();
batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
float x = getX();
float y = getY();
float scaleX = getScaleX();
float scaleY = getScaleY();
if (drawable instanceof TransformDrawable) {
float rotation = getRotation();
if (scaleX != 1 || scaleY != 1 || rotation != 0) {
((TransformDrawable) drawable).draw(batch, x + imageX, y + imageY, getOriginX() - imageX, getOriginY() - imageY, imageWidth, imageHeight, scaleX, scaleY, rotation);
return;
}
}
if (drawable != null)
drawable.draw(batch, x + imageX, y + imageY, imageWidth * scaleX, imageHeight * scaleY);
}
use of com.badlogic.gdx.scenes.scene2d.utils.TransformDrawable in project bladecoder-adventure-engine by bladecoder.
the class DefaultSceneScreen method drawHotspots.
private void drawHotspots(SpriteBatch batch) {
final World world = World.getInstance();
for (BaseActor a : world.getCurrentScene().getActors().values()) {
if (!(a instanceof InteractiveActor) || !a.isVisible() || a == world.getCurrentScene().getPlayer())
continue;
InteractiveActor ia = (InteractiveActor) a;
if (!ia.canInteract())
continue;
Polygon p = a.getBBox();
if (p == null) {
EngineLogger.error("ERROR DRAWING HOTSPOT FOR: " + a.getId());
}
Rectangle r = a.getBBox().getBoundingRectangle();
unprojectTmp.set(r.getX() + r.getWidth() / 2, r.getY() + r.getHeight() / 2, 0);
world.getSceneCamera().scene2screen(viewport, unprojectTmp);
if (!showDesc || ia.getDesc() == null) {
float size = DPIUtils.ICON_SIZE * DPIUtils.getSizeMultiplier();
if (ia.getVerb("leave") != null) {
TransformDrawable drawable = (TransformDrawable) getUI().getSkin().getDrawable("leave");
drawable.draw(batch, unprojectTmp.x - size / 2, unprojectTmp.y - size / 2, size / 2, size / 2, size, size, 1.0f, 1.0f, calcLeaveArrowRotation(ia));
} else {
Drawable drawable = getUI().getSkin().getDrawable("hotspot");
if (drawable != null)
drawable.draw(batch, unprojectTmp.x - size / 2, unprojectTmp.y - size / 2, size, size);
}
} else {
BitmapFont font = getUI().getSkin().getFont("desc");
String desc = ia.getDesc();
if (desc.charAt(0) == I18N.PREFIX)
desc = I18N.getString(desc.substring(1));
textLayout.setText(font, desc);
float textX = unprojectTmp.x - textLayout.width / 2;
float textY = unprojectTmp.y + textLayout.height;
RectangleRenderer.draw(batch, textX - 8, textY - textLayout.height - 8, textLayout.width + 16, textLayout.height + 16, Color.BLACK);
font.draw(batch, textLayout, textX, textY);
}
}
}
Aggregations