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

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

Introduction

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

Prototype

public Color(Color color) 

Source Link

Document

Constructs a new color using the given color

Usage

From source file:Screens.LoadingScreen.java

@Override
public void show() {
    stage = new Stage();
    camera = new OrthographicCamera();

    font = assets.manager.get(ScreenAssets.font);

    renderer = new ShapeRenderer();
    progress = 0f;/*  ww  w  . j  a v a 2s.  c om*/

    /**Styles*/
    lbl_style = new Label.LabelStyle();
    lbl_style.font = font;
    lbl_style.fontColor = new Color(Color.WHITE);
    progress_percentage = new Label("Loading : " + "(" + progress + ")", lbl_style);
    progress_percentage.setPosition(RacingGame.V_HEIGHT / 2, RacingGame.V_WIDTH / 2 - 510);

    OnePlayer = new Label("CONTROLS FOR PLAYER 1", lbl_style);
    OnePlayer.setPosition(500, 500);

    arrows_controls = assets.manager.get(ScreenAssets.arrows_controls);
    arrows_Image = new Image(arrows_controls);
    arrows_Image.setPosition(550, 400);

    if (twoPlayers) {
        //put 1P and 2P controls
        ASDW_controls = assets.manager.get(ScreenAssets.ASDW_controls);
        TwoPlayer = new Label("CONTROLS FOR PLAYER 2", lbl_style);
        ASDW_Image = new Image(ASDW_controls);

        arrows_Image.setPosition(700, 400);
        ASDW_Image.setPosition(300, 400);
        OnePlayer.setPosition(650, 500);
        TwoPlayer.setPosition(250, 500);

        stage.addActor(ASDW_Image);
        stage.addActor(TwoPlayer);
    }

    stage.addActor(progress_percentage);
    stage.addActor(arrows_Image);
    stage.addActor(OnePlayer);

}

From source file:Screens.MapSelectionScreen.java

@Override
public void show() {
    //Gdx.app.log("Map Selection", "show called");
    stage = new Stage();
    Gdx.input.setInputProcessor(stage); //** stage is responsive **//

    click = assets.manager.get(ScreenAssets.click_sound);
    click2 = assets.manager.get(ScreenAssets.click_sound2);

    /**Texture*///from w w  w. j  a  v  a 2s.  com
    title_texture = assets.manager.get(ScreenAssets.mapTitle);

    file = new FileHandle("data/maps.txt");
    group = file.readString().split("\n");
    mapTitles = group[0].split(",");
    map = group[1].split(",");

    /** BitmapFont */
    font = assets.manager.get(ScreenAssets.font);

    /** Atlas and skin */
    buttons_atlas = assets.manager.get(ScreenAssets.buttons_atlas);
    buttons_skin = new Skin(buttons_atlas);

    /** Styles */
    ready_style = new ImageButton.ImageButtonStyle(buttons_skin.getDrawable("READY_button"), null, null, null,
            null, null);
    back_style = new ImageButton.ImageButtonStyle(buttons_skin.getDrawable("back_button"), null, null, null,
            null, null);
    nextmap_style = new ImageButton.ImageButtonStyle(buttons_skin.getDrawable("nextarrow_big"), null, null,
            null, null, null);
    prevmap_style = new ImageButton.ImageButtonStyle(buttons_skin.getDrawable("backarrow_big"), null, null,
            null, null, null);

    lbl_style = new Label.LabelStyle();
    lbl_style.font = font;
    lbl_style.fontColor = new Color(Color.WHITE);

    /** Title */
    title = new Image(title_texture);
    title.setPosition(280, 648);

    /** Buttons */
    ready_btn = new ImageButton(ready_style);
    ready_btn.setPosition(1016, 24);
    back_btn = new ImageButton(back_style);
    back_btn.setPosition(24, 24);

    selectPreviousMapButton = new ImageButton(prevmap_style);
    selectPreviousMapButton.setX(150);
    selectPreviousMapButton.setY(300);
    selectNextMapButton = new ImageButton(nextmap_style);
    selectNextMapButton.setX(1058);
    selectNextMapButton.setY(300);

    /** Map Preview*/
    preview = new Image(new Texture(Gdx.files.internal(map[0])));
    preview.setPosition(320, 160);
    preview.setSize(650, 380);
    stage.addActor(preview);

    /** Map Title*/
    map_title = new Label(mapTitles[0], lbl_style);
    map_title.setPosition(350, 130);
    stage.addActor(map_title);

    stage.addActor(selectPreviousMapButton);
    stage.addActor(selectNextMapButton);
    stage.addActor(ready_btn);
    stage.addActor(back_btn);
    stage.addActor(title);

    listeners();

}

From source file:Screens.PlayerScreen.java

@Override
public void show() {
    //Gdx.app.log("PlayerScreen", "show called");
    stage = new Stage();
    Gdx.input.setInputProcessor(stage);//w  ww.  j  av a2  s .  c  om

    click = assets.manager.get(ScreenAssets.click_sound);

    /** BitmapFont */
    font = assets.manager.get(ScreenAssets.font);

    /** textures*/
    title_texture = assets.manager.get(ScreenAssets.playerTitle);

    /** Atlas and skin */
    buttons_atlas = assets.manager.get(ScreenAssets.buttons_atlas);
    buttons_skin = new Skin(buttons_atlas);
    atlas = assets.manager.get(ScreenAssets.atlas);
    skin = new Skin(atlas);

    /** Styles */
    next_style = new ImageButton.ImageButtonStyle(buttons_skin.getDrawable("next_button"), null, null, null,
            null, null);
    back_style = new ImageButton.ImageButtonStyle(buttons_skin.getDrawable("back_button"), null, null, null,
            null, null);
    txt_style = new TextField.TextFieldStyle();
    txt_style.background = skin.getDrawable("textfield");
    txt_style.cursor = skin.getDrawable("cursor");
    txt_style.selection = skin.getDrawable("selection");
    txt_style.font = font;
    txt_style.fontColor = new Color(Color.WHITE);
    lbl_style = new Label.LabelStyle();
    lbl_style.font = font;
    lbl_style.fontColor = new Color(Color.WHITE);

    /**Title*/
    title = new Image(title_texture);
    title.setPosition(280, 648);

    /** Label Racer 1*/
    racer1_title = new Label("Racer 1", lbl_style);
    racer1_title.setPosition(550, 500);

    /** Player name box */
    racer1 = new Image(new Texture(Gdx.files.internal("menu/player_name_box.png")));
    racer1.setPosition(500, 400);

    /** Name field*/
    txt_field1 = new TextField("Enter Name", txt_style);
    txt_field1.setSize(290, 40);
    txt_field1.setPosition(500, 455);
    txt_field1.setMaxLength(16);

    /** Next / Back buttons */
    next_btn = new ImageButton(next_style);
    next_btn.setPosition(1016, 24);
    back_btn = new ImageButton(back_style);
    back_btn.setPosition(24, 24);

    /** Two players */
    if (twoPlayers == true) {
        racer2 = new Image(new Texture(Gdx.files.internal("menu/player_name_box.png")));
        racer2.setPosition(500, 200);

        racer2_title = new Label("Racer 2", lbl_style);
        racer2_title.setPosition(550, 300);

        txt_field2 = new TextField("Enter Name", txt_style);
        txt_field2.setSize(290, 40);
        txt_field2.setPosition(500, 255);
        txt_field2.setMaxLength(16);

        stage.addActor(racer2);
        stage.addActor(racer2_title);
        stage.addActor(txt_field2);
    }

    /** Add actors*/
    stage.addActor(racer1);
    stage.addActor(racer1_title);
    stage.addActor(txt_field1);
    stage.addActor(back_btn);
    stage.addActor(next_btn);
    stage.addActor(title);

    listeners();
}

From source file:seventh.client.gfx.Art.java

License:Open Source License

/**
 * Loads the image from the file system, with a supplied color mask
 * @param image/*from   w  ww  .  j  ava 2  s  . c  o m*/
 * @param mask the color to change to transparent
 * @return the texture
 */
public static TextureRegion loadImage(String image, int mask) {
    try {
        Pixmap map = TextureUtil.loadPixmap(image);
        TextureRegion region = TextureUtil.tex(TextureUtil.applyMask(map, new Color((mask << 8) | 0xff)));
        map.dispose();

        return region;
    } catch (Exception e) {
        Cons.println("*** A problem occured loading an image: " + e);
    }

    return new TextureRegion(TextureUtil.createImage(10, 10));
}

From source file:seventh.client.gfx.Art.java

License:Open Source License

public static AnimatedImage newAnimatedSplitImage(int[] frameTimes, Pixmap image, int row, int col,
        Integer mask) {/*from   w  ww. j a v  a  2 s.  com*/
    if (mask != null) {
        Pixmap oldimage = image;
        image = TextureUtil.applyMask(image, new Color(mask));
        oldimage.dispose();
    }

    Animation animation = newAnimation(frameTimes);
    TextureRegion[] images = TextureUtil.splitImage(TextureUtil.tex(image), row, col);

    return new AnimatedImage(images, animation);
}

From source file:seventh.client.gfx.Colors.java

License:Open Source License

public static Vector3f toVector3f(int color) {
    Color c = new Color(color);
    return new Vector3f(c.r, c.g, c.b);
}

From source file:seventh.client.gfx.effects.particle_system.Emitters.java

License:Open Source License

private static Emitter _newFireEmitter(Vector2f pos) {
    int emitterTimeToLive = 2_400;
    int maxParticles = 140;
    int maxSpread = 40;

    Emitter emitter = new Emitter(pos, emitterTimeToLive, maxParticles).setName("FireEmitter")
            .setDieInstantly(false);//from  w w w  .  j  av  a2  s. c om
    BatchedParticleGenerator gen = new BatchedParticleGenerator(0, 5)
            .addSingleParticleGenerator(new RandomColorSingleParticleGenerator(new Color(0xEB5aaFff),
                    new Color(0xEB502Fff), new Color(0x434B43ff)))
            .addSingleParticleGenerator(new SingleParticleGenerator() {

                @Override
                public void onGenerateParticle(int index, TimeStep timeStep, ParticleData particles) {
                    particles.color[index].a = 0.92f;
                }
            }).addSingleParticleGenerator(new RandomPositionInRadiusGrowthSingleParticleGenerator(1, maxSpread))
            //  .addSingleParticleGenerator(new RandomRotationSingleParticleGenerator())
            .addSingleParticleGenerator(new RandomScaleSingleParticleGenerator(0.355f, 0.362f))
            .addSingleParticleGenerator(new RandomScaleGrowthSingleParticleGenerator(2.4f))
            .addSingleParticleGenerator(new RandomSpeedSingleParticleGenerator(80, 140))
            .addSingleParticleGenerator(new RandomTimeToLiveSingleParticleGenerator(100, 200))
            .addSingleParticleGenerator(new RandomSpriteSingleParticleGenerator(Art.smokeImage));

    emitter.addParticleGenerator(gen);

    emitter.addParticleUpdater(new KillUpdater());
    // emitter.addParticleUpdater(new KillIfAttachedIsDeadUpdater());        
    emitter.addParticleUpdater(new RandomMovementParticleUpdater(880));
    emitter.addParticleUpdater(new AlphaDecayUpdater(0f, 0.9498f));
    //emitter.addParticleUpdater(new ScaleUpdater(2.3f, 0.08f));
    emitter.addParticleRenderer(new BlendingSpriteParticleRenderer());
    emitter.setLifeCycleListener(new EmitterLifeCycleListener() {

        @Override
        public void onKilled(Emitter emitter) {
            fireEmitterPool.free(emitter);
        }
    });

    return emitter;
}

From source file:seventh.client.gfx.effects.particle_system.Emitters.java

License:Open Source License

public static Emitter newBulletImpactFleshEmitter(Vector2f pos, Vector2f targetVel) {
    // 5, 5200, 4000, 0, 60);
    // int maxParticles, int emitterTimeToLive, int particleTimeToLive, int timeToNextSpawn, int maxSpread) {

    Vector2f vel = targetVel.isZero() ? new Vector2f(-1.0f, -1.0f)
            : new Vector2f(-targetVel.x * 1.0f, -targetVel.y * 1.0f);

    Emitter emitter = new Emitter(pos, 200, 30).setName("BulletImpactFleshEmitter").setDieInstantly(false);
    BatchedParticleGenerator gen = new BatchedParticleGenerator(0, 30);
    gen.addSingleParticleGenerator(new SingleParticleGenerator() {

        @Override// w  w w. j av  a  2  s.  com
        public void onGenerateParticle(int index, TimeStep timeStep, ParticleData particles) {
            particles.speed[index] = 125f;
        }
    }).addSingleParticleGenerator(new SetPositionSingleParticleGenerator())
            .addSingleParticleGenerator(
                    new RandomColorSingleParticleGenerator(new Color(0x660000ff), new Color(0x330000ff)))
            .addSingleParticleGenerator(new RandomVelocitySingleParticleGenerator(vel, 120))
            .addSingleParticleGenerator(new RandomTimeToLiveSingleParticleGenerator(600, 950));

    emitter.addParticleGenerator(gen);

    emitter.addParticleUpdater(new KillUpdater());
    emitter.addParticleUpdater(new RandomMovementParticleUpdater(45));
    emitter.addParticleUpdater(new AlphaDecayUpdater(0f, 0.82718f));
    emitter.addParticleRenderer(new CircleParticleRenderer());

    return emitter;
}

From source file:seventh.client.gfx.effects.particle_system.Emitters.java

License:Open Source License

public static Emitter newRocketTrailEmitter(Vector2f pos, int emitterTimeToLive) {
    //int emitterTimeToLive = 10_000;
    int maxParticles = 1000;
    int maxSpread = 15;

    Emitter emitter = new Emitter(pos, emitterTimeToLive, maxParticles).setName("RocketTrailEmitter")
            .setDieInstantly(false);//from w w w  .j  a v  a  2  s.c o  m
    BatchedParticleGenerator gen = new BatchedParticleGenerator(0, 7)
            .addSingleParticleGenerator(
                    new RandomColorSingleParticleGenerator(new Color(0x474B48ff), new Color(0x434B43ff)))
            .addSingleParticleGenerator(new SingleParticleGenerator() {

                @Override
                public void onGenerateParticle(int index, TimeStep timeStep, ParticleData particles) {
                    particles.color[index].a = 0.92f;
                }
            }).addSingleParticleGenerator(new RandomPositionInRadiusSingleParticleGenerator(maxSpread))
            .addSingleParticleGenerator(new RandomRotationSingleParticleGenerator())
            .addSingleParticleGenerator(new RandomScaleSingleParticleGenerator(0.25f, 1.2f))
            .addSingleParticleGenerator(new RandomSpeedSingleParticleGenerator(0, 0))
            .addSingleParticleGenerator(new RandomTimeToLiveSingleParticleGenerator(5500, 6000))
            .addSingleParticleGenerator(new RandomSpriteSingleParticleGenerator(Art.smokeImage));

    emitter.addParticleGenerator(gen);

    emitter.addParticleUpdater(new KillUpdater());
    emitter.addParticleUpdater(new KillIfAttachedIsDeadUpdater());
    emitter.addParticleUpdater(new RandomMovementParticleUpdater(80));
    emitter.addParticleUpdater(new AlphaDecayUpdater(0f, 0.9498f));
    emitter.addParticleRenderer(new SpriteParticleRenderer());

    return emitter;
}

From source file:seventh.client.gfx.effects.particle_system.Emitters.java

License:Open Source License

public static Emitter newSmokeEmitter(Vector2f pos, int emitterTimeToLive, int colorStart, int colorEnd,
        int maxSpread, float minSize, float maxSize, boolean killIfAttachedIsDead) {
    int maxParticles = 1500;

    Emitter emitter = new Emitter(pos, emitterTimeToLive, maxParticles).setName("SmokeEmitter")
            .setDieInstantly(false);//  w w w  .  ja  v  a 2  s  .c  om
    BatchedParticleGenerator gen = new BatchedParticleGenerator(100, 4)
            .addSingleParticleGenerator(
                    new RandomColorSingleParticleGenerator(new Color(colorStart), new Color(colorEnd)))
            .addSingleParticleGenerator(new SingleParticleGenerator() {

                @Override
                public void onGenerateParticle(int index, TimeStep timeStep, ParticleData particles) {
                    particles.color[index].a = 0.32f;
                }
            }).addSingleParticleGenerator(new RandomPositionInRadiusSingleParticleGenerator(maxSpread))
            .addSingleParticleGenerator(new RandomRotationSingleParticleGenerator())
            .addSingleParticleGenerator(new RandomScaleSingleParticleGenerator(minSize, maxSize))
            .addSingleParticleGenerator(new RandomSpeedSingleParticleGenerator(1, 1))
            .addSingleParticleGenerator(new RandomVelocitySingleParticleGenerator(new Vector2f(1, 0), 180))
            .addSingleParticleGenerator(new RandomTimeToLiveSingleParticleGenerator(3800, 4000))
            .addSingleParticleGenerator(new RandomSpriteSingleParticleGenerator(Art.smokeImage));

    emitter.addParticleGenerator(gen);

    if (killIfAttachedIsDead)
        emitter.addParticleUpdater(new KillIfAttachedIsDeadUpdater());
    emitter.addParticleUpdater(new KillUpdater());
    emitter.addParticleUpdater(new RandomMovementParticleUpdater(20));
    //emitter.addParticleUpdater(new MovementParticleUpdater(0, 40f));
    emitter.addParticleUpdater(new AlphaDecayUpdater(0f, 0.9898f));
    emitter.addParticleRenderer(new SpriteParticleRenderer());

    return emitter;
}