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

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

Introduction

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

Prototype

Color RED

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

Click Source Link

Usage

From source file:com.algodal.gdxscreen.GdxGame.java

License:Apache License

public GdxGame() {
    screenMap = new ArrayMap<>();
    transitionMap = new ArrayMap<>();
    assetMap = new ArrayMap<>();
    assetManager = new AssetManager();

    defaultScreen = new GdxScreen().setGame(this);
    screenListener = new ScreenListener();

    debug = new GdxDebug().setOn(true); //debugging is on by default
    //I like this kind of coding where I embed debugging within my main
    //code.  I find it useful because it allows me to avoid using large
    //amount of nested if statements.  In this code I do not have to add
    //comment to the debug code because the tag strings are descriptive.

    library = new GdxLibrary();

    clearColor = new Color(Color.RED);

    pauseStatus = false; //initially the game is not paused.
}

From source file:com.andgate.pokeadot.PlayResultsScreen.java

License:Open Source License

public PlayResultsScreen(PokeADot currentGame) {
    game = currentGame;/* www. jav a2 s  . co  m*/
    stage = new Stage();
    Gdx.input.setInputProcessor(stage);

    boolean newHighScore = false;
    if (game.mode == PokeADot.GameMode.PLAY) {
        HighScore currentHighScore = HighScoreService.get();
        if (game.gameTime >= currentHighScore.time) {
            HighScoreService.set(new HighScore(game.gameTime));
            newHighScore = true;
        }
    }

    // Retry and exit buttons
    final ImageButton nextButton = game.createIconButton(Constants.GO_ICON_LOCATION,
            Constants.GO_ICON_DOWN_LOCATION, new ClickListener() {
                @Override
                public void clicked(InputEvent event, float x, float y) {
                    game.buttonPressedSound.play();
                    goMainMenu();
                }
            });

    final ImageButton replayButton = game.createIconButton(Constants.REPLAY_ICON_LOCATION,
            Constants.REPLAY_ICON_DOWN_LOCATION, new ClickListener() {
                @Override
                public void clicked(InputEvent event, float x, float y) {
                    game.buttonPressedSound.play();
                    goReplay();
                }
            });

    // display information about the game depending on the currently selected mode.
    final Label.LabelStyle titleLabelStyle = new Label.LabelStyle(game.largeFont, Color.ORANGE);
    final Label.LabelStyle infoLabelStyle = new Label.LabelStyle(game.mediumSmallFont, Color.LIGHT_GRAY);
    final Label.LabelStyle newHighScoreLabelStyle = new Label.LabelStyle(game.mediumSmallFont, Color.RED);

    final Label resultsLabel = new Label("Result", titleLabelStyle);
    final Label timeLabel = new Label(String.format("Time: %.2f", game.gameTime) + " seconds", infoLabelStyle);
    final Label newHighScoreLabel = new Label("New high score!", newHighScoreLabelStyle);

    //table.debugAll();

    final Table resultsTable = new Table();
    resultsTable.add(resultsLabel).center().spaceBottom(25.0f).row();
    resultsTable.add(timeLabel).top().center().row();

    if (newHighScore) {
        resultsTable.add(newHighScoreLabel).top().center().row();
    }

    final Table buttonsTable = new Table();
    buttonsTable.add(replayButton).left();
    buttonsTable.add(nextButton).expandX().right();

    final Table table = new Table();
    table.setFillParent(true);
    table.add(resultsTable).top().center().spaceBottom(25.0f).row();
    //table.add(replayButton).left();
    //table.add(nextButton).right();
    table.add(buttonsTable).fill();

    stage.addActor(table);
}

From source file:com.badlogic.gdx.graphics.g3d.test.KeyframedModelViewer.java

License:Apache License

@Override
public void render() {
    Gdx.gl.glClearColor(0.2f, 0.2f, 0.2f, 1.0f);
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
    Gdx.gl.glEnable(GL10.GL_DEPTH_TEST);

    cam.update();//from w  w  w.j  a v  a 2  s .  c o  m
    cam.apply(Gdx.gl10);

    drawAxes();

    if (hasNormals) {
        Gdx.gl.glEnable(GL10.GL_LIGHTING);
        Gdx.gl.glEnable(GL10.GL_COLOR_MATERIAL);
        Gdx.gl.glEnable(GL10.GL_LIGHT0);
        Gdx.gl10.glLightfv(GL10.GL_LIGHT0, GL10.GL_DIFFUSE, lightColor, 0);
        Gdx.gl10.glLightfv(GL10.GL_LIGHT0, GL10.GL_POSITION, lightPosition, 0);
    }

    if (texture != null) {
        Gdx.gl.glEnable(GL10.GL_TEXTURE_2D);
        texture.bind();
    }

    angle += 45 * Gdx.graphics.getDeltaTime();
    animTime += Gdx.graphics.getDeltaTime();
    if (animTime >= anim.totalDuration) {
        animTime = 0;
    }

    model.setAnimation(anim.name, animTime, false);
    for (int i = 0; i < 20; i++) {
        Gdx.gl10.glPushMatrix();
        Gdx.gl10.glTranslatef(0, 0, -100 + i * 10);
        model.render();
        Gdx.gl10.glPopMatrix();
    }

    if (texture != null) {
        Gdx.gl.glDisable(GL10.GL_TEXTURE_2D);
    }

    if (hasNormals) {
        Gdx.gl.glDisable(GL10.GL_LIGHTING);
    }

    batch.begin();
    font.setColor(Color.RED);
    font.draw(batch, "fps: " + Gdx.graphics.getFramesPerSecond(), 20, 30);
    batch.end();
}

From source file:com.badlogic.gdx.tests.dragome.examples.GearsDemo.java

@Override
public void create() {

    environment = new Environment();
    environment.set(new ColorAttribute(ColorAttribute.AmbientLight, .2f, .2f, .2f, 2f));
    //      environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, 0f, -0.5f, -0.5f));

    sl = new PointLight().setPosition(-5, 10, -6).setColor(1, 1, 1, 1).setIntensity(150);

    //      sl2 = new PointLight().setPosition(0, 7, 5).setColor(0.3f, 0.8f, 0.3f, 1)
    //         .setIntensity(20);
    ///*  ww w  .  j  a v a  2s .  c o m*/
    //      sl3 = new PointLight().setPosition(0, 9, 6).setColor(0.3f, 0.3f, 0.8f, 1)
    //         .setIntensity(20);

    environment.add(sl);
    //      environment.add(sl2);
    //      environment.add(sl3);

    cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cam.position.set(-10, 3, 10f);
    cam.lookAt(-3, 0, 0);
    cam.near = 1f;
    cam.far = 100f;
    cam.update();

    cameraController = new CameraInputController(cam);
    cameraController.autoUpdate = false;
    cameraController.forwardTarget = false;
    cameraController.translateTarget = false;

    Gdx.input.setInputProcessor(new InputMultiplexer(cameraController));

    time = TimeUtils.millis();

    viewport = new ScreenViewport(cam);
    guiViewport = new ScreenViewport();

    DefaultShaderProvider defaultShaderProvider = new DefaultShaderProvider();
    modelBatch = new ModelBatch(defaultShaderProvider);

    ModelBuilder modelBuilder = new ModelBuilder();
    model1 = gear(modelBuilder, 1.0f, 4.0f, 1.0f, 20, 0.7f, Color.RED);
    gear1 = new ModelInstance(model1);

    model2 = gear(modelBuilder, 0.5f, 2.0f, 2.0f, 10, 0.7f, Color.GREEN);
    gear2 = new ModelInstance(model2);

    model3 = gear(modelBuilder, 1.3f, 2.0f, 1.5f, 10, 0.7f, Color.BLUE);
    gear3 = new ModelInstance(model3);

    font = new BitmapFont();

    batch = new SpriteBatch();

    lightModel = modelBuilder.createSphere(1, 1, 1, 10, 10,
            new Material(ColorAttribute.createDiffuse(1, 1, 1, 1)), Usage.Position);
    lightModel.nodes.get(0).parts.get(0).setRenderable(pLight = new Renderable());
}

From source file:com.badlogic.gdx.tests.HelloWorld.java

License:Apache License

@Override
public void create() {
    gl = Gdx.gl10;/*w  w w.j a  v  a 2 s . co m*/
    gl.glDisable(GL10.GL_DEPTH_TEST);
    //      gl.glEnable(GL10.GL_DEPTH_TEST);
    //      gl.glDisable(GL10.GL_TEXTURE_2D);
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
    gl.glClearColor(0, 0, 0, 1);

    font = new BitmapFont();
    font.setColor(Color.RED);
    texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));
    spriteBatch = new SpriteBatch();
}

From source file:com.badlydrawngames.general.SimpleButton.java

License:Apache License

public void draw(SpriteBatch spriteBatch) {
    Color oldColor = font.getColor();
    if (down) {/*from ww  w  .j  a v a  2 s .  c o  m*/
        spriteBatch.setColor(Color.RED);
    } else {
        spriteBatch.setColor(Color.BLUE);
    }
    spriteBatch.draw(Assets.pureWhiteTextureRegion, x, y, w, h);
    spriteBatch.setColor(Color.WHITE);
    if (down) {
        font.setColor(oldColor.r / 2, oldColor.g / 2, oldColor.b / 2, oldColor.a);
    }
    float textX = x;
    float textY = y + h;
    textY -= (h - textHeight) / 2;
    font.drawWrapped(spriteBatch, text, textX, textY, w, alignment);
    font.setColor(oldColor);
}

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

License:Apache License

@Override
public void draw(SpriteBatch batch, float x, float y, float scale) {

    if (tex == null) {
        x = x - getWidth() / 2 * scale;/* www .j  a v  a 2s.  c  o  m*/

        RectangleRenderer.draw(batch, x, y, getWidth() * scale, getHeight() * scale, Color.RED);
        return;
    }

    x = x + tex.offsetX - tex.originalWidth / 2;
    y = y + tex.offsetY - tex.originalHeight * (1 - scale) / 2;

    if (!flipX) {
        batch.draw(tex, x, y, tex.originalWidth / 2 - tex.offsetX, tex.originalHeight / 2 - tex.offsetY,
                tex.packedWidth, tex.packedHeight, scale, scale, 0);
    } else {
        batch.draw(tex, x, y, tex.originalWidth / 2 - tex.offsetX, tex.originalHeight / 2 - tex.offsetY,
                tex.packedWidth, tex.packedHeight, -scale, scale, 0);
    }
}

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

License:Apache License

@Override
public void draw(SpriteBatch batch, float x, float y, float scale) {

    x = x - getWidth() / 2 * scale; // SET THE X ORIGIN TO THE CENTER OF THE
    // SPRITE/*from   w ww  .  j  ava  2  s . co  m*/

    if (currentSource == null || currentSource.tex == null) {
        RectangleRenderer.draw(batch, x, y, getWidth() * scale, getHeight() * scale, Color.RED);
        return;
    }

    if (!flipX) {
        batch.draw(currentSource.tex, x, y, currentSource.tex.getWidth() * scale,
                currentSource.tex.getHeight() * scale);
    } else {
        batch.draw(currentSource.tex, x, y, -currentSource.tex.getWidth() * scale,
                currentSource.tex.getHeight() * scale);
    }
}

From source file:com.bladecoder.engine.spine.SpineRenderer.java

License:Apache License

@Override
public void draw(SpriteBatch batch, float x, float y, float scale) {

    if (currentSource != null && currentSource.skeleton != null) {
        currentSource.skeleton.setX(x / scale);
        currentSource.skeleton.setY(y / scale);

        batch.setTransformMatrix(batch.getTransformMatrix().scale(scale, scale, 1.0f));
        renderer.draw(batch, currentSource.skeleton);
        batch.setTransformMatrix(batch.getTransformMatrix().scale(1 / scale, 1 / scale, 1.0f));
    } else {/*from ww w. ja va 2  s. c om*/
        x = x - getWidth() / 2 * scale;
        RectangleRenderer.draw(batch, x, y, getWidth() * scale, getHeight() * scale, Color.RED);
    }
}

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

License:Apache License

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

    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);
        }

    }
}