Example usage for com.badlogic.gdx.graphics Color WHITE

List of usage examples for com.badlogic.gdx.graphics Color WHITE

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics Color WHITE.

Prototype

Color WHITE

To view the source code for com.badlogic.gdx.graphics Color WHITE.

Click Source Link

Usage

From source file:com.bladecoder.engine.actions.Param.java

License:Apache License

public static Color parseColor(String color) {
    if (color == null || color.trim().isEmpty()) {
        return null; // the default color in the style will be used
    }/*from ww  w. j  a  va 2 s  .co m*/

    switch (color.trim()) {
    case "black":
        return Color.BLACK;
    case "white":
        return Color.WHITE;
    default:
        return Color.valueOf(color);
    }
}

From source file:com.bladecoder.engine.model.Scene.java

License:Apache License

public void drawBBoxLines(ShapeRenderer renderer) {
    // renderer.begin(ShapeType.Rectangle);
    renderer.begin(ShapeType.Line);

    for (BaseActor a : actors.values()) {
        Polygon p = a.getBBox();/*from   w  w w.ja v  a2  s . c o m*/

        if (p == null) {
            EngineLogger.error("ERROR DRAWING BBOX FOR: " + a.getId());
        }

        if (a instanceof ObstacleActor) {
            renderer.setColor(OBSTACLE_COLOR);
            renderer.polygon(p.getTransformedVertices());
        } else if (a instanceof AnchorActor) {
            renderer.setColor(Scene.ANCHOR_COLOR);
            renderer.line(p.getX() - Scene.ANCHOR_RADIUS, p.getY(), p.getX() + Scene.ANCHOR_RADIUS, p.getY());
            renderer.line(p.getX(), p.getY() - Scene.ANCHOR_RADIUS, p.getX(), p.getY() + Scene.ANCHOR_RADIUS);
        } else {
            renderer.setColor(ACTOR_BBOX_COLOR);
            renderer.polygon(p.getTransformedVertices());
        }

        // Rectangle r = a.getBBox().getBoundingRectangle();
        // renderer.rect(r.getX(), r.getY(), r.getWidth(), r.getHeight());
    }

    if (polygonalNavGraph != null) {
        renderer.setColor(WALKZONE_COLOR);
        renderer.polygon(polygonalNavGraph.getWalkZone().getTransformedVertices());

        // DRAW LINEs OF SIGHT
        renderer.setColor(Color.WHITE);
        ArrayList<NavNodePolygonal> nodes = polygonalNavGraph.getGraphNodes();
        for (NavNodePolygonal n : nodes) {
            for (NavNodePolygonal n2 : n.neighbors) {
                renderer.line(n.x, n.y, n2.x, n2.y);
            }
        }
    }

    renderer.end();
}

From source file:com.bladecoder.engine.ui.CreditsScreen.java

License:Apache License

public void drawCenteredScreenX(SpriteBatch batch, BitmapFont font, CharSequence str, float y,
        int viewportWidth) {
    float x = 0;//  w w  w.j a  v  a2  s.  c o m

    layout.setText(font, str, Color.WHITE, viewportWidth, Align.center, true);

    //x = (viewportWidth - layout.width)/2;

    font.draw(batch, layout, x, y);
}

From source file:com.bladecoder.engine.ui.defaults.DefaultSceneScreen.java

License:Apache License

private void drawDebugText(SpriteBatch batch) {
    World w = World.getInstance();/* w ww . j  a v  a 2s.  c  om*/

    w.getSceneCamera().getInputUnProject(viewport, unprojectTmp);

    Color color;

    sbTmp.setLength(0);

    if (EngineLogger.lastError != null) {
        sbTmp.append(EngineLogger.lastError);

        color = Color.RED;
    } else {

        sbTmp.append("( ");
        sbTmp.append((int) unprojectTmp.x);
        sbTmp.append(", ");
        sbTmp.append((int) unprojectTmp.y);
        sbTmp.append(") FPS:");
        sbTmp.append(Gdx.graphics.getFramesPerSecond());
        // sbTmp.append(" Density:");
        // sbTmp.append(Gdx.graphics.getDensity());
        // sbTmp.append(" UI Multiplier:");
        // sbTmp.append(DPIUtils.getSizeMultiplier());
        sbTmp.append(" UI STATE: ");
        sbTmp.append(state.toString());
        sbTmp.append(' ');

        long millis = w.getTimeOfGame();
        long second = (millis / 1000) % 60;
        long minute = (millis / (1000 * 60)) % 60;
        long hour = (millis / (1000 * 60 * 60));

        String time = String.format("%02d:%02d:%02d", hour, minute, second);

        sbTmp.append(time);

        //         if (w.getCurrentScene().getPlayer() != null) {
        //            sbTmp.append(" Depth Scl: ");
        //            sbTmp.append(w.getCurrentScene().getFakeDepthScale(unprojectTmp.y));
        //         }

        color = Color.WHITE;
    }

    String strDebug = sbTmp.toString();

    textLayout.setText(ui.getSkin().getFont("debug"), strDebug, color, viewport.getScreenWidth(), Align.left,
            true);
    RectangleRenderer.draw(batch, 0, viewport.getScreenHeight() - textLayout.height - 10, textLayout.width,
            textLayout.height + 10, Color.BLACK);
    ui.getSkin().getFont("debug").draw(batch, textLayout, 0, viewport.getScreenHeight() - 5);

    // Draw actor states when debug
    if (EngineLogger.getDebugLevel() == EngineLogger.DEBUG1) {

        for (BaseActor a : w.getCurrentScene().getActors().values()) {

            if (a instanceof AnchorActor)
                continue;

            Rectangle r = a.getBBox().getBoundingRectangle();
            sbTmp.setLength(0);
            sbTmp.append(a.getId());
            if (a instanceof InteractiveActor && ((InteractiveActor) a).getState() != null)
                sbTmp.append(".").append(((InteractiveActor) a).getState());

            unprojectTmp.set(r.getX(), r.getY(), 0);
            w.getSceneCamera().scene2screen(viewport, unprojectTmp);
            ui.getSkin().getFont("debug").draw(batch, sbTmp.toString(), unprojectTmp.x, unprojectTmp.y);
        }

    }
}

From source file:com.bladecoder.engine.ui.defaults.ScenePointer.java

License:Apache License

public void draw(SpriteBatch batch, Viewport v) {

    getInputUnproject(v, mousepos);/*from  w  w  w.  j  av  a2s  .c  o  m*/

    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 (draggingRenderer == 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 = (draggingRenderer.getHeight() > draggingRenderer.getWidth() ? draggingRenderer.getHeight()
                : draggingRenderer.getWidth());
        float size = DPIUtils.getTouchMinSize() / h * 1.8f;

        if (currentIcon != hotspotIcon) {
            batch.setColor(DRAG_NOT_HOTSPOT_COLOR);
        }

        draggingRenderer.draw(batch, mousepos.x, mousepos.y - draggingRenderer.getHeight() * size / 2, size);

        if (currentIcon != hotspotIcon) {
            batch.setColor(Color.WHITE);
        }
    }
}

From source file:com.bladecoder.engine.ui.InitScreen.java

License:Apache License

@Override
public void render(float delta) {
    SpriteBatch batch = ui.getBatch();//from w  w w  .j  av  a  2  s  .c o m

    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    batch.setProjectionMatrix(viewport.getCamera().combined);
    batch.begin();

    if (time > FADE_TIME * 2 + SCREEN_TIME) { // EXIT INIT SCREEN
        batch.setColor(Color.WHITE);
        ui.setCurrentScreen(Screens.MENU_SCREEN);
    } else if (time > FADE_TIME + SCREEN_TIME) { // FADE_OUT
        batch.setColor(1, 1, 1, 1 - fadeTime / FADE_TIME);
    } else if (time < FADE_TIME) { // FADE IN
        batch.setColor(1, 1, 1, fadeTime / FADE_TIME);
    } else {
        fadeTime = 0;
    }

    final int viewportW = viewport.getScreenWidth();
    final int viewportH = viewport.getScreenHeight();
    final float texW = tex.getWidth() * scale;
    final float texH = tex.getHeight() * scale;
    batch.draw(tex, (viewportW - texW) / 2, (viewportH - texH) / 2, texW, texH);
    batch.setColor(1, 1, 1, 1);

    time += delta;
    fadeTime += delta;
    batch.end();
}

From source file:com.bladecoder.engine.ui.LoadingScreen.java

License:Apache License

@Override
public void render(float delta) {

    // Try to load scene for WAIT_TIME_MS before continue. If not loaded in
    // this time,
    // show the loading screen
    if (wait) {/*from  w  w  w.jav a2s  .  co m*/
        float t0 = System.currentTimeMillis();
        float t = 0f;
        while (EngineAssetManager.getInstance().isLoading() && t - t0 < WAIT_TIME_MS) {
            t = System.currentTimeMillis();
        }
    }

    if (!EngineAssetManager.getInstance().isLoading()) {
        ui.setCurrentScreen(Screens.SCENE_SCREEN);
        return;
    }

    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    // Only show the squares when time > INIT_TIME
    if (initTime < INIT_TIME_SEG) {
        initTime += delta;
        return;
    }

    final SpriteBatch batch = ui.getBatch();

    batch.setProjectionMatrix(viewport.getCamera().combined);
    batch.begin();

    update(delta);

    for (int i = 0; i < numSquares; i++) {
        final Color color = i == pos ? Color.WHITE : Color.GRAY;
        RectangleRenderer.draw(ui.getBatch(), x + i * (squareWidth + margin), y, squareWidth, squareHeight,
                color);
    }
    batch.end();
}

From source file:com.bladecoder.engine.ui.Pointer.java

License:Apache License

@Override
public void draw(Batch batch, float alpha) {

    getInputUnproject(getStage().getViewport(), mousepos);

    setPosition(mousepos.x - getWidth() / 2, mousepos.y - getHeight() / 2);

    batch.setColor(Color.WHITE);

    batch.draw(pointerIcon, getX(), getY(), getWidth(), getHeight());
}

From source file:com.bladecoder.engine.ui.retro.RetroSceneScreen.java

License:Apache License

private void drawDebugText(SpriteBatch batch) {
    World w = World.getInstance();//from  w w w. j  a v  a2s .  c  o  m

    w.getSceneCamera().getInputUnProject(worldViewport, unprojectTmp);

    Color color;

    sbTmp.setLength(0);

    if (EngineLogger.lastError != null) {
        sbTmp.append(EngineLogger.lastError);

        color = Color.RED;
    } else {

        sbTmp.append("( ");
        sbTmp.append((int) unprojectTmp.x);
        sbTmp.append(", ");
        sbTmp.append((int) unprojectTmp.y);
        sbTmp.append(") FPS:");
        sbTmp.append(Gdx.graphics.getFramesPerSecond());
        // sbTmp.append(" Density:");
        // sbTmp.append(Gdx.graphics.getDensity());
        // sbTmp.append(" UI Multiplier:");
        // sbTmp.append(DPIUtils.getSizeMultiplier());
        sbTmp.append(" UI STATE: ");
        sbTmp.append(state.toString());

        if (w.getCurrentScene().getPlayer() != null) {
            sbTmp.append(" Depth Scl: ");
            sbTmp.append(w.getCurrentScene().getFakeDepthScale(unprojectTmp.y));
        }

        color = Color.WHITE;
    }

    String strDebug = sbTmp.toString();

    textLayout.setText(ui.getSkin().getFont("debug"), strDebug, color, worldViewport.getScreenWidth(),
            Align.left, true);

    RectangleRenderer.draw(batch, 0, worldViewport.getScreenHeight() - textLayout.height - 10, textLayout.width,
            textLayout.height + 10, Color.BLACK);
    ui.getSkin().getFont("debug").draw(batch, textLayout, 0, worldViewport.getScreenHeight() - 5);

    // Draw actor states when debug
    if (EngineLogger.getDebugLevel() == EngineLogger.DEBUG1) {

        for (BaseActor a : w.getCurrentScene().getActors().values()) {
            Rectangle r = a.getBBox().getBoundingRectangle();
            sbTmp.setLength(0);
            sbTmp.append(a.getId());
            if (a instanceof InteractiveActor && ((InteractiveActor) a).getState() != null)
                sbTmp.append(".").append(((InteractiveActor) a).getState());

            unprojectTmp.set(r.getX(), r.getY(), 0);
            w.getSceneCamera().scene2screen(worldViewport, unprojectTmp);

            if (w.getInventory().isVisible()) {
                // unprojectTmp.y += verbUI.getHeight();
            }

            ui.getSkin().getFont("debug").draw(batch, sbTmp.toString(), unprojectTmp.x, unprojectTmp.y);
        }

    }
}

From source file:com.bladecoder.engine.ui.TextManagerUI.java

License:Apache License

@Override
public void draw(Batch batch, float alpha) {
    batch.setColor(Color.WHITE);

    final TextManagerUIStyle style = getStyle(subtitle);

    if (subtitle.type == Text.Type.TALK) {
        if (getX() < 0 || getX() > getStage().getViewport().getScreenWidth())
            return;

        if (style.talkBubble != null) {
            float scale = DPIUtils.getTouchMinSize() / 4 / style.talkBubble.getMinHeight();

            float bubbleX = unprojectTmp.x - style.talkBubble.getMinWidth() * scale / 2;
            bubbleX = Math.max(bubbleX, getX() + PADDING);
            bubbleX = Math.min(bubbleX, getStage().getViewport().getScreenWidth() - PADDING);
            float bubbleY = getY() - style.talkBubble.getMinHeight() * scale + 2;

            style.talkBubble.draw(batch, bubbleX, bubbleY, style.talkBubble.getMinWidth() * scale,
                    style.talkBubble.getMinHeight() * scale);
        }/*from   ww  w  . j  a va  2  s . c om*/

        if (style.talkBackground != null) {
            style.talkBackground.draw(batch, getX(), getY(), getWidth(), getHeight());
        }

    } else if (subtitle.type == Text.Type.SUBTITLE) {
        if (style.rectBackground != null) {
            style.rectBackground.draw(batch, getX(), getY(), getWidth(), getHeight());
        }
    }

    style.font.draw(batch, layout, fontX, getY() + PADDING + layout.height);
}