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.mob.client.sprites.CharacterSprite.java

License:Open Source License

public CharacterSprite(Game _game, int x, int y, Heading mHeading, int bodyIndex, int weaponIndex,
        int headIndex, int helmetIndex, int shieldIndex, int fxIndex) {
    super(_game, x, y);

    // Init class
    this.mFont = this.mGame.getFont();
    this.mFont.setColor(0.0f, 0.6f, 0.0f, 1.0f);
    this.mHeading = mHeading;
    this.mDeltaTime = 0.0f;
    this.mBodyGrhIndex = 0;
    this.mHeadGrhIndex = 0;
    this.mHelmetGrhIndex = 0;
    this.mWeaponGrhIndex = 0;
    this.mShieldGrhIndex = 0;
    this.mFxGrhIndex = 0;
    this.mFxOffsetX = 0;
    this.mFxOffsetY = 0;
    this.mFxTimer = 0;
    this.mColor = Color.WHITE;

    // Check null indexes
    if (helmetIndex == 0)
        helmetIndex = 2;/*from   w  ww.java  2  s .c  o  m*/
    if (weaponIndex == 0)
        weaponIndex = 2;
    if (shieldIndex == 0)
        shieldIndex = 2;

    // Load graphics
    if (bodyIndex != 0)
        this.loadBody(this.mGame.getBodyData().get(bodyIndex));
    if (weaponIndex != 0)
        this.loadWeapon(this.mGame.getWeaponData().get(weaponIndex));
    if (shieldIndex != 0)
        this.loadShield(this.mGame.getShieldData().get(shieldIndex));
    if (headIndex != 0)
        this.loadHead(this.mGame.getHeadData().get(headIndex));
    if (helmetIndex != 0)
        this.loadHelmet(this.mGame.getHelmetData().get(helmetIndex));
    if (fxIndex != 0)
        this.loadFx(this.mGame.getFxData().get(fxIndex));

    // Calculate offsets
    this.mHeadOffsetX = this.mGame.getBodyData().get(bodyIndex).getHeadOffsetX();
    this.mHeadOffsetY = this.mGame.getBodyData().get(bodyIndex).getHeadOffsetY();
}

From source file:com.momia.asg.screens.MainMenu.java

License:Apache License

public MainMenu(final ASG game) {
    this.game = game;
    batch = new SpriteBatch();
    stage = new Stage();
    Gdx.input.setInputProcessor(stage);/*from ww w . java  2 s  .c  o  m*/
    // A skin can be loaded via JSON or defined programmatically, either is fine. Using a skin is optional but strongly
    // recommended solely for the convenience of getting a texture, region, etc as a drawable, tinted drawable, etc.
    skin = new Skin();
    // Generate a 1x1 white texture and store it in the skin named "white".
    Pixmap pixmap = new Pixmap(1, 1, Format.RGBA8888);
    pixmap.setColor(Color.WHITE);
    pixmap.fill();
    skin.add("white", new Texture(pixmap));
    // Store the default libgdx font under the name "default".
    skin.add("default", new BitmapFont());
    // Configure a TextButtonStyle and name it "default". Skin resources are stored by type, so this doesn't overwrite the font.
    TextButtonStyle textButtonStyle = new TextButtonStyle();
    textButtonStyle.up = skin.newDrawable("white", Color.DARK_GRAY);
    textButtonStyle.down = skin.newDrawable("white", Color.DARK_GRAY);
    textButtonStyle.checked = skin.newDrawable("white", Color.BLUE);
    textButtonStyle.over = skin.newDrawable("white", Color.LIGHT_GRAY);
    textButtonStyle.font = skin.getFont("default");
    skin.add("default", textButtonStyle);
    // Create a table that fills the screen. Everything else will go inside this table.
    Table table = new Table();
    table.setFillParent(true);
    stage.addActor(table);
    // Create a button with the "default" TextButtonStyle. A 3rd parameter can be used to specify a name other than "default".
    final TextButton button = new TextButton("New Game", skin);
    table.add(button);
    // Add a listener to the button. ChangeListener is fired when the button's checked state changes, eg when clicked,
    // Button#setChecked() is called, via a key press, etc. If the event.cancel() is called, the checked state will be reverted.
    // ClickListener could have been used, but would only fire when clicked. Also, canceling a ClickListener event won't
    // revert the checked state.
    button.addListener(new ClickListener() {
        public void clicked(InputEvent event, float x, float y) {
            if (button.isChecked())
                game.setScreen(new Screen1(game));
        }
    });

}

From source file:com.mygdx.g3il.screens.MainMenuScreen.java

License:Apache License

@Override
public void draw(float delta) {
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    camera.update();//from  ww w. j a va2 s.co  m

    ShapeRenderer shapeRenderer = new ShapeRenderer();
    shapeRenderer.setProjectionMatrix(camera.combined);
    shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
    shapeRenderer.setColor(1, 1, 0, 1);
    shapeRenderer.rect(playBounds.x, playBounds.y, playBounds.getWidth(), playBounds.getHeight());
    shapeRenderer.rect(highscoresBounds.x, highscoresBounds.y, highscoresBounds.getWidth(),
            highscoresBounds.getHeight());
    shapeRenderer.end();

    game.batch.setProjectionMatrix(camera.combined);
    game.batch.setColor(Color.WHITE);
    game.batch.begin();
    game.batch.disableBlending();
    game.batch.draw(background, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    game.batch.end();

    game.batch.enableBlending();
    game.batch.begin();
    final Vector2 position = new Vector2();
    drawText("Play", playBounds.getCenter(position));
    drawText("High Scores", highscoresBounds.getCenter(position));
    //drawText("Help", helpBounds.getCenter(position));
    game.batch.end();
}

From source file:com.mygdx.game.CrossroadDrawer.java

public void draw() {
    sr.begin();/*  ww  w .j a v  a2 s.c  o m*/
    sr.set(ShapeRenderer.ShapeType.Filled);

    // ? 
    sr.setColor(Color.DARK_GRAY);
    sr.rect(0, Constants.heightWindow / 2 - scaleRoad, Constants.widthWindow, scaleRoad * 2);

    // ? 
    sr.setColor(Color.DARK_GRAY);
    sr.rect(Constants.widthWindow / 2 - scaleRoad, 0, scaleRoad * 2, Constants.heightWindow);

    //  
    sr.setColor(Color.WHITE);
    float x = Constants.widthWindow / 2 - scaleRoad - crossroads.widthCrosswalk - crossroads.widthCrosswalk / 2;
    float y = Constants.heightWindow / 2 - scaleRoad + crossroads.heightCrosswalk / 2;

    while (y < Constants.heightWindow / 2 + scaleRoad) {

        sr.rect(x, y, crossroads.widthCrosswalk, crossroads.heightCrosswalk);
        y += 2 * crossroads.heightCrosswalk;
    }

    //  
    x = Constants.widthWindow / 2 + scaleRoad + crossroads.widthCrosswalk / 2;
    y = Constants.heightWindow / 2 - scaleRoad + crossroads.heightCrosswalk / 2;

    while (y < Constants.heightWindow / 2 + scaleRoad) {

        sr.rect(x, y, crossroads.widthCrosswalk, crossroads.heightCrosswalk);
        y += 2 * crossroads.heightCrosswalk;
    }

    // ? ?-?
    x = Constants.widthWindow / 2 - scaleRoad - crossroads.widthCrosswalk - crossroads.widthCrosswalk / 2
            - 3 * crossroads.heightCrosswalk;
    y = Constants.heightWindow / 2 - scaleRoad + crossroads.heightCrosswalk;
    sr.rect(x, y, crossroads.heightCrosswalk, scaleRoad - 2 * crossroads.heightCrosswalk);

    // ? ? ?? ?
    sr.rect(0, Constants.heightWindow / 2 - scaleMarking, x - scaleMarking * 2, scaleMarking);

    //  ? 
    float step = scaleRoad / 3;

    float startShortMarking = 0;

    while (startShortMarking + crossroads.widthShortMarking < x - scaleMarking * 2) {
        sr.rect(startShortMarking, Constants.heightWindow / 2 - scaleMarking - step,
                crossroads.widthShortMarking, scaleMarking);
        sr.rect(startShortMarking, Constants.heightWindow / 2 - scaleMarking - 2 * step,
                crossroads.widthShortMarking, scaleMarking);
        sr.rect(startShortMarking, Constants.heightWindow / 2 - scaleMarking + step,
                crossroads.widthShortMarking, scaleMarking);
        sr.rect(startShortMarking, Constants.heightWindow / 2 - scaleMarking + 2 * step,
                crossroads.widthShortMarking, scaleMarking);
        startShortMarking += 2 * crossroads.widthShortMarking;
    }

    // ? ?-?
    x = Constants.widthWindow / 2 + scaleRoad + crossroads.widthCrosswalk + crossroads.widthCrosswalk / 2
            + 2 * crossroads.heightCrosswalk;
    y = Constants.heightWindow / 2 + crossroads.heightCrosswalk;
    sr.rect(x, y, crossroads.heightCrosswalk, scaleRoad - 2 * crossroads.heightCrosswalk);

    // ? ? ?? ?
    sr.rect(x + 2 * crossroads.heightCrosswalk, Constants.heightWindow / 2 - scaleMarking, x - scaleMarking * 2,
            scaleMarking);

    //  ? 
    startShortMarking = x + 2 * crossroads.widthShortMarking;
    while (startShortMarking < Constants.widthWindow) {
        sr.rect(startShortMarking, Constants.heightWindow / 2 - scaleMarking - step,
                crossroads.widthShortMarking, scaleMarking);
        sr.rect(startShortMarking, Constants.heightWindow / 2 - scaleMarking - 2 * step,
                crossroads.widthShortMarking, scaleMarking);
        sr.rect(startShortMarking, Constants.heightWindow / 2 - scaleMarking + step,
                crossroads.widthShortMarking, scaleMarking);
        sr.rect(startShortMarking, Constants.heightWindow / 2 - scaleMarking + 2 * step,
                crossroads.widthShortMarking, scaleMarking);
        startShortMarking += 2 * crossroads.widthShortMarking;
    }

    //  
    x = Constants.widthWindow / 2 - scaleRoad + crossroads.heightCrosswalk / 2;
    y = Constants.heightWindow / 2 + scaleRoad + crossroads.widthCrosswalk / 2;

    while (x < Constants.widthWindow / 2 + scaleRoad - crossroads.heightCrosswalk) {
        sr.rect(x, y, crossroads.heightCrosswalk, crossroads.widthCrosswalk);
        x += 2 * crossroads.heightCrosswalk;
    }

    // ?? ?-?
    x = Constants.widthWindow / 2 - scaleRoad + crossroads.heightCrosswalk / 2;
    y = Constants.heightWindow / 2 + scaleRoad + crossroads.widthCrosswalk / 2 + crossroads.widthCrosswalk
            + 2 * crossroads.heightCrosswalk;
    sr.rect(x, y, scaleRoad - 2 * crossroads.heightCrosswalk, crossroads.heightCrosswalk);

    // ?? ? ?
    sr.rect(Constants.widthWindow / 2 - scaleMarking, y + 2 * crossroads.heightCrosswalk, scaleMarking,
            Constants.heightWindow / 2);

    //  ? 
    startShortMarking = y + 2 * crossroads.widthShortMarking;
    while (startShortMarking < Constants.heightWindow) {
        sr.rect(Constants.widthWindow / 2 - scaleMarking - step, startShortMarking, scaleMarking,
                crossroads.widthShortMarking);
        sr.rect(Constants.widthWindow / 2 - scaleMarking - 2 * step, startShortMarking, scaleMarking,
                crossroads.widthShortMarking);
        sr.rect(Constants.widthWindow / 2 - scaleMarking + step, startShortMarking, scaleMarking,
                crossroads.widthShortMarking);
        sr.rect(Constants.widthWindow / 2 - scaleMarking + 2 * step, startShortMarking, scaleMarking,
                crossroads.widthShortMarking);
        startShortMarking += 2 * crossroads.widthShortMarking;
    }

    //  
    x = Constants.widthWindow / 2 - scaleRoad + crossroads.heightCrosswalk / 2;
    y = Constants.heightWindow / 2 - scaleRoad - crossroads.widthCrosswalk / 2 - crossroads.widthCrosswalk;

    while (x < Constants.widthWindow / 2 + scaleRoad - crossroads.heightCrosswalk) {
        sr.rect(x, y, crossroads.heightCrosswalk, crossroads.widthCrosswalk);
        x += 2 * crossroads.heightCrosswalk;
    }

    // ?? ?-?
    x = Constants.widthWindow / 2 + crossroads.heightCrosswalk / 2;
    y = Constants.heightWindow / 2 - scaleRoad - crossroads.widthCrosswalk / 2 - crossroads.widthCrosswalk
            - 3 * crossroads.heightCrosswalk;
    sr.rect(x, y, scaleRoad - 2 * crossroads.heightCrosswalk, crossroads.heightCrosswalk);

    // ?? ? ?
    sr.rect(Constants.widthWindow / 2 - scaleMarking, 0, scaleMarking, y - crossroads.heightCrosswalk);

    //  ? 
    startShortMarking = y - 2 * crossroads.widthShortMarking;
    while (startShortMarking > 0) {
        sr.rect(Constants.widthWindow / 2 - scaleMarking - step, startShortMarking, scaleMarking,
                crossroads.widthShortMarking);
        sr.rect(Constants.widthWindow / 2 - scaleMarking - 2 * step, startShortMarking, scaleMarking,
                crossroads.widthShortMarking);
        sr.rect(Constants.widthWindow / 2 - scaleMarking + step, startShortMarking, scaleMarking,
                crossroads.widthShortMarking);
        sr.rect(Constants.widthWindow / 2 - scaleMarking + 2 * step, startShortMarking, scaleMarking,
                crossroads.widthShortMarking);
        startShortMarking -= 2 * crossroads.widthShortMarking;
    }

    motion();

    // 
    for (Vehicle next : Data.vehicles) {
        next.performDraw(sr);
    }

    // ?
    tld1.draw();
    tld2.draw();
    tld3.draw();
    tld4.draw();

    sr.end();
}

From source file:com.mygdx.game.debugdrawers.NavMeshDebugDrawer.java

License:Apache License

private void drawPathPoints(NavMeshPointPath navMeshPointPath) {
    shapeRenderer.set(MyShapeRenderer.ShapeType.Line);
    Vector3 q;/*  w  w  w  .j a  v  a 2s  . c  o  m*/
    Vector3 p = navMeshPointPath.getVector(navMeshPointPath.getSize() - 1);
    shapeRenderer.setColor(Color.WHITE);
    for (int i = navMeshPointPath.getSize() - 1; i >= 0; i--) {
        q = navMeshPointPath.getVector(i);
        shapeRenderer.setColor(Color.CYAN);
        shapeRenderer.line(p, q);
        p = q;
        drawVertex(p, 0.02f, Color.WHITE);
    }
}

From source file:com.mygdx.game.debugdrawers.NavMeshDebugDrawer.java

License:Apache License

public void drawClosestPointDebug(GameCharacter character) {
    Vector3 position = tmp1;//from www.  j a v a 2s  .  c om
    Vector3 direction = tmp2;
    Vector3 closestPoint = tmp3;
    Vector3 aimPoint = tmp4;
    float radius = 2;
    character.getDirection(direction);
    character.getGroundPosition(position);
    aimPoint.set(direction).scl(radius).add(position);
    Triangle closest = navMesh.getClosestValidPointAt(position, direction, radius, closestPoint,
            character.visibleOnLayers);

    shapeRenderer.set(MyShapeRenderer.ShapeType.Filled);
    shapeRenderer.setColor(0, 0, 1, 0.2f);
    shapeRenderer.triangle(closest.a, closest.b, closest.c);
    drawVertex(aimPoint, 0.05f, Color.GREEN);
    drawVertex(closestPoint, 0.05f, Color.WHITE);

}

From source file:com.mygdx.game.gameword.GameRenderer.java

public GameRenderer(GameWorld gameWorld) {
    this.gameWorld = gameWorld;
    this.batch = new SpriteBatch();
    this.wait = new BitmapFont();
    this.time = new BitmapFont();
    wait.setColor(Color.WHITE);
    time.setColor(Color.WHITE);/*from   ww  w. ja v a 2 s .  c o  m*/
    GlyphLayout waitLayout = new GlyphLayout();
    waitLayout.setText(wait, "Veuillez appuyer sur n'importe quelle touche pour lancer le jeu !");
    waitWidth = waitLayout.width;
    waitHeight = waitLayout.height;
}

From source file:com.mygdx.game.HideAndSeek.HideAndSeekScreen.java

@Override
public void render(float delta) {
    // clear the screen with a dark blue color. The
    // arguments to glClearColor are the red, green
    // blue and alpha component in the range [0,1]
    // of the color to be used to clear the screen.
    Gdx.gl.glClearColor(0, 0, 0, 1);/*  ww w.ja  v  a2  s. c  o m*/
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    // tell the camera to update its matrices.
    camera.update();

    // tell the SpriteBatch to render in the
    // coordinate system specified by the camera.
    has.batch.setProjectionMatrix(camera.combined);

    // begin a new batch and draw the bucket and
    // all drops
    if (FOG_OF_WAR) {
        shapeRenderer.setColor(Color.WHITE);
        shapeRenderer.begin(ShapeType.Filled);
        shapeRenderer.circle(seeker.x + seeker.imageWidth / 2, seeker.y + seeker.imageHeight / 2,
                seeker.SIGHT_RANGE);
        shapeRenderer.end();
    }

    has.batch.begin();
    for (Entity e : hiders) {
        double distance = Math.sqrt(Math.pow(e.x + e.imageWidth / 2 - seeker.x - seeker.imageWidth / 2, 2)
                + Math.pow(e.y + e.imageHeight / 2 - seeker.y - seeker.imageHeight / 2, 2));
        if (distance + Math.sqrt(e.imageWidth / 2) < seeker.SIGHT_RANGE) {
            has.batch.draw(e.image, e.x, e.y);
        }
    }
    has.batch.draw(seeker.image, seeker.x, seeker.y);
    has.batch.end();

    seeker.act(delta, has);
}

From source file:com.mygdx.game.LoadingGameScreen.java

License:Apache License

@Override
public void renderProgress(float delta, float progress) {
    Gdx.gl.glClearColor(Color.BLACK.r, Color.BLACK.g, Color.BLACK.b, Color.BLACK.a);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    shapeRenderer.setProjectionMatrix(camera.projection);
    shapeRenderer.setTransformMatrix(camera.view);
    shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
    float x = (GdxDemo3D.WIDTH - PROGRESS_BAR_WIDTH) / 2;
    float y = (GdxDemo3D.HEIGHT - PROGRESS_BAR_HEIGHT) / 2;
    float k = 4;//from  www. j  av  a  2 s . c o m
    shapeRenderer.setColor(Color.WHITE);
    shapeRenderer.rect(x - k, y - k, PROGRESS_BAR_WIDTH + k * 2, PROGRESS_BAR_HEIGHT + k * 2);
    shapeRenderer.setColor(Color.BLUE);
    shapeRenderer.rect(x, y, PROGRESS_BAR_WIDTH * progress, PROGRESS_BAR_HEIGHT);
    shapeRenderer.end();
}

From source file:com.mygdx.game.screens.GameChooserScreen.java

private void create() {
    //Create a font
    BitmapFont font = new BitmapFont();
    skin = new Skin();
    skin.add("default", font);

    //Create a texture
    Pixmap pixmap = new Pixmap((int) Gdx.graphics.getWidth() / 4, (int) Gdx.graphics.getHeight() / 10,
            Pixmap.Format.RGB888);
    pixmap.setColor(Color.WHITE);
    pixmap.fill();//from  w w  w  .  j  a v  a  2 s  .  com
    skin.add("background", new Texture(pixmap));

    //Create a button style
    TextButton.TextButtonStyle textButtonStyle = new TextButton.TextButtonStyle();
    textButtonStyle.up = skin.newDrawable("background", Color.GRAY);
    textButtonStyle.down = skin.newDrawable("background", Color.DARK_GRAY);
    textButtonStyle.checked = skin.newDrawable("background", Color.DARK_GRAY);
    textButtonStyle.over = skin.newDrawable("background", Color.LIGHT_GRAY);
    textButtonStyle.font = skin.getFont("default");
    skin.add("default", textButtonStyle);
}