List of usage examples for com.badlogic.gdx.graphics Color Color
public Color(float r, float g, float b, float a)
From source file:com.esotericsoftware.spine.superspineboy.EnemyView.java
License:Open Source License
EnemyView(final View view, Enemy enemy) { super(view);/*from w ww. j ava2s . c o m*/ this.enemy = enemy; skeleton = new Skeleton(view.assets.enemySkeletonData); burstHeadAttachment = skeleton.getAttachment("head", "burst01"); headSlot = skeleton.findSlot("head"); hitAnimation = skeleton.getData().findAnimation("hit"); animationState = new AnimationState(view.assets.enemyAnimationData); // Play squish sound when enemies die. final EventData squishEvent = view.assets.enemySkeletonData.findEvent("squish"); animationState.addListener(new AnimationStateAdapter() { public void event(int trackIndex, Event event) { if (event.getData() == squishEvent) SoundEffect.squish.play(); } }); // Enemies have slight color variations. if (enemy.type == Type.strong) headColor = new Color(1, 0.6f, 1, 1); else headColor = new Color(MathUtils.random(0.8f, 1), MathUtils.random(0.8f, 1), MathUtils.random(0.8f, 1), 1); headSlot.getColor().set(headColor); }
From source file:com.exovum.test.animation.AnimatorMenuScreen.java
License:Creative Commons License
public AnimatorMenuScreen(final Game game) { this.batch = new SpriteBatch(); this.game = game; screen = this; menuBackground = new Texture(Gdx.files.internal("beach-ocean-sea-bg/transparent-png/full_background.png")); menuMusic = Gdx.audio.newMusic(Gdx.files.internal("Carpe Diem.mp3")); stage = new Stage(new FitViewport(800, 480)); Gdx.input.setInputProcessor(stage);/*from w w w .ja v a2 s . c o m*/ // Setup the UI skin. Pass the TextureAtlas too so it can find the default settings. TextureAtlas skinAtlas = new TextureAtlas(Gdx.files.internal("uiskin.atlas")); skin = new Skin(Gdx.files.internal("uiskin.json"), skinAtlas); mainTable = new Table(skin); //mainTable.defaults().expand().fill().padBottom(4f).padTop(4f); mainTable.setFillParent(true); // Add the title of the game at the top of the MenuScreen titleTable = new Table(skin); final Label titleLabel = new Label("Kordan Jirby", skin, "title"); titleLabel.setColor(Color.FIREBRICK); //titleLabel.setStyle(new Label.LabelStyle(titleFont, Color.FIREBRICK)); titleLabel.setAlignment(Align.center, Align.center); titleLabel.setPosition(stage.getWidth() / 2, stage.getHeight()); //titleLabel.setFontScale(2.0f); titleTable.defaults().expand().fill().padBottom(4f).padTop(4f); titleTable.add(titleLabel); titleTable.padBottom(10f); // Bottom/Base Table: left-child holds buttonTable for menu buttons, // right-child holds some text info ie instructions or credits baseTable = new Table(skin); baseTable.defaults().expand().fill().padBottom(10f).padTop(10f); // Add the buttons for the user to press: play, help, credits, exit TextButton playButton = new TextButton("Play Game", skin, "small-font"); TextButton helpButton = new TextButton("Instructions", skin, "small-font"); TextButton creditsButton = new TextButton("Credits", skin, "small-font"); TextButton exitButton = new TextButton("Exit", skin, "small-font"); Table buttonTable = new Table(skin); // Add the button table as the left-child to baseTable baseTable.add(buttonTable); //menuTable.setBackground("console2"); // Set the color of the BACKGROUND on the buttons Color buttonColor = Color.SKY; Gdx.app.log("AnimatorMenuScreen", "Color RGB SKY: " + Color.SKY.toString()); playButton.setColor(buttonColor); helpButton.setColor(buttonColor); creditsButton.setColor(buttonColor); exitButton.setColor(buttonColor); // Set the color of the TEXT on the buttons //buttonColor = new Color(0.845f, 0.845f, 0.845f, 1); buttonColor = new Color(0.91f, 0.91f, 0.91f, 1); playButton.getLabel().setColor(buttonColor); helpButton.getLabel().setColor(buttonColor); creditsButton.getLabel().setColor(buttonColor); exitButton.getLabel().setColor(buttonColor); buttonTable.defaults().expand().fill().padBottom(8f).padTop(2f); buttonTable.add(playButton).width(180f).height(60f).row(); buttonTable.add(helpButton).width(180f).height(60f).row(); buttonTable.add(creditsButton).width(180f).height(60f).row(); buttonTable.add(exitButton).width(180f).height(60f); buttonTable.padTop(30f).padBottom(30f); buttonTable.left(); /* Temporary removal of infoTable It was not easy for me to add hidden/new text and for the layouts to update correctly. Changing plan to create a new Screen for Credits (and instructions too). */ infoTable = new Table(skin); // = new Label("", skin, "small-font"); infoTable.setVisible(false); infoTable.defaults().expand().fill().padBottom(8f).padTop(2f); //baseTable.add(infoTable); // Add title table at the top of mainTable mainTable.add(titleTable).row(); // Add baseTable containing buttonTable to the next row of mainTable //mainTable.add(buttonTable); mainTable.add(baseTable); // Add mainTable to the stage stage.addActor(mainTable); // Event Listeners for the menu buttons playButton.addListener(new ChangeListener() { public void changed(ChangeEvent event, Actor actor) { Gdx.app.log("AnimatorMenuScreen", "Pressed playButton"); //game.setScreen(new AnimatorGameScreen(game, screen)); ((Game) Gdx.app.getApplicationListener()).setScreen(new AnimatorGameScreen(game, screen)); } }); helpButton.addListener(new ChangeListener() { public void changed(ChangeEvent event, Actor actor) { Gdx.app.log("AnimatorMenuScreen", "Pressed helpButton"); //game.setScreen(new InstructionsScreen(game, screen)); ((Game) Gdx.app.getApplicationListener()).setScreen(new InstructionsScreen(game, screen)); } }); creditsButton.addListener(new ChangeListener() { public void changed(ChangeEvent event, Actor actor) { Gdx.app.log("AnimatorMenuScreen", "Pressed creditsButton"); //game.setScreen(new CreditsScreen(game, screen)); ((Game) Gdx.app.getApplicationListener()).setScreen(new CreditsScreen(game, screen)); /* * Attempt at adding text next to the buttons. * Status: Unsuccessful. Updating the layout once adding the credits text * does not update as easily as I hoped. * Changing plan to use different Screens for Credits & Instructions. // If the table is visible and already showing credits, then 'minimize' infoTable if(infoTable.isVisible() && infoTable.getName() != null && infoTable.getName().equals("Credits")) { Gdx.app.log("AnimatorMenuScreen", "Hide the credits menu"); infoTable.setVisible(false); infoTable.clearChildren(); } else { Gdx.app.log("AnimatorMenuScreen", "Display the credits text"); // Otherwise, make the infoTable visible and set text to the credits infoTable.setVisible(true); infoTable.clearChildren(); //infoTable.center(); Label musicLabel = new Label("Music\n" + "Pixel Peeker Polka - slower Kevin MacLeod (incompetech.com)\n" + "Licensed under Creative Commons: By Attribution 3.0 License\n" + "http://creativecommons.org/licenses/by/3.0/", skin, "small-font"); musicLabel.setColor(Color.BLACK); //infoTable.addActor(musicLabel); infoTable.addActor(musicLabel); infoTable.padLeft(20f); //musicLabel.setPosition(stage.getWidth() / 2 + 50, stage.getHeight() / 2 + 100, Align.right); infoTable.defaults().expand().fill().padBottom(8f).padTop(2f); musicLabel.setWidth(200f); //musicLabel.setWrap(true); musicLabel.setAlignment(Align.center); //musicLabel.setFillParent(true); // "Invalidates this actor's layout, causing layout() to happen next time // validate() is called infoTable.invalidate(); baseTable.invalidate(); infoTable.center(); //infoTable.setFillParent(true); //titleTable.add(musicLabel); } infoTable.setName("Credits"); */ } }); exitButton.addListener(new ChangeListener() { public void changed(ChangeEvent event, Actor actor) { Gdx.app.log("AnimatorMenuScreen", "Pressed exitButton - exiting application"); Gdx.app.exit(); } }); }
From source file:com.exovum.test.animation.CreditsScreen.java
License:Creative Commons License
public CreditsScreen(final Game game, Screen parentScreen) { this.batch = new SpriteBatch(); this.game = game; this.parent = parentScreen; Gdx.app.log("CreditsScreen", "Creating CreditsScreen"); menuBackground = new Texture(Gdx.files.internal("beach-ocean-sea-bg/transparent-png/full_background.png")); stage = new Stage(new FitViewport(800, 480)); Gdx.input.setInputProcessor(stage);//from w w w.j a va 2 s . c o m skin = new Skin(Gdx.files.internal("uiskin.json")); mainTable = new Table(skin); //mainTable.defaults().expand().fill().padBottom(4f).padTop(4f); mainTable.setFillParent(true); baseTable = new Table(skin); baseTable.defaults().expand().fill().padBottom(10f).padTop(10f); Label myHeader = new Label("General", skin, "small-font"); myHeader.setColor(Color.FIREBRICK); myHeader.setAlignment(Align.center); Label myCredits = new Label("Programming and Development\n" + "Caleb Stevenson", skin, "small-font"); myCredits.setColor(Color.BLACK); myCredits.setAlignment(Align.center); Label musicHeader = new Label("Music", skin, "small-font"); musicHeader.setColor(Color.FIREBRICK); musicHeader.setAlignment(Align.center); Label musicCredits = new Label("\"Capre Diem\", \"Hidden Past\", \"Pixel Peeker Polka - slower\"\n" + "Kevin MacLeod (incompetech.com)\n" + "Licensed under Creative Commons: By Attribution 3.0\n" + "http://creativecommons.org/licenses/by/3.0/", skin, "small-font"); musicCredits.setColor(Color.BLACK); musicCredits.setAlignment(Align.center); Label artHeader = new Label("Artwork", skin, "small-font"); artHeader.setColor(Color.FIREBRICK); artHeader.setAlignment(Align.center); Label artCredits = new Label("Background and Tree Sprites\n" + "http://bevouliin.com\nopengameart.org", skin, "small-font"); artCredits.setColor(Color.BLACK); artCredits.setAlignment(Align.center); TextButton exitButton = new TextButton("Back to Menu", skin, "small-font"); Table buttonTable = new Table(skin); baseTable.add(myHeader).row(); baseTable.add(myCredits).row(); baseTable.add(musicHeader).row(); baseTable.add(musicCredits).row(); baseTable.add(artHeader).row(); baseTable.add(artCredits).row(); baseTable.add(buttonTable); //menuTable.setBackground("console2"); // Set the color of the BACKGROUND on the buttons Color buttonColor = Color.SKY; exitButton.setColor(buttonColor); // Set the color of the TEXT on the buttons exitButton.getLabel().setColor(new Color(0.91f, 0.91f, 0.91f, 1)); buttonTable.defaults().expand().fill().padBottom(4f).padTop(2f); buttonTable.add(exitButton).width(180f).height(60f); //buttonTable.padTop(20f).padBottom(20f); buttonTable.left(); // Add baseTable containing buttonTable to the next row of mainTable //mainTable.add(buttonTable); mainTable.add(baseTable); // Add mainTable to the stage stage.addActor(mainTable); exitButton.addListener(new ChangeListener() { public void changed(ChangeEvent event, Actor actor) { Gdx.app.log("CreditsScreen", "Exiting to main menu"); //game.setScreen(new AnimatorMenuScreen(game)); //game.setScreen(parent); //((Game) Gdx.app.getApplicationListener()).setScreen(parent); ((Game) Gdx.app.getApplicationListener()).setScreen(new AnimatorMenuScreen(game)); } }); //Use an InputMultiplexer so that the Stage and keyDown input processors can both be used InputMultiplexer multiplexer = new InputMultiplexer(); multiplexer.addProcessor(stage); multiplexer.addProcessor(new InputAdapter() { // If the back key is pressed, go to main menu // This also handles the Android 'back' button @Override public boolean keyDown(int keycode) { if (keycode == Input.Keys.BACK) { // Handle the back button Gdx.app.log("CreditsScreen", "KeyDown: BACK pressed"); //AnimatorMenuScreen newMenu = new AnimatorMenuScreen(batch, game); //game.setScreen(newMenu); //game.setScreen(parent); //((Game) Gdx.app.getApplicationListener()).setScreen(parent); ((Game) Gdx.app.getApplicationListener()).setScreen(new AnimatorMenuScreen(game)); return true; } return false; } }); Gdx.input.setInputProcessor(multiplexer); }
From source file:com.explatcreations.sft.graphics.background.ParchmentBackground.java
License:Open Source License
public ParchmentBackground() { final Patch bg = Patch.makeCharred(Width + 8, Height + 8); this.fade = new RectSprite(Game.RenderWidth, Game.RenderHeight, new Color(0, 0, 0, MaxAlpha)); final ArrayList<Integer> pages = NotesPanel.getRandomPages(); int pageIndex = 0; for (int i = 0; i < Math.max(left.length, right.length); i += 1) { if (i < left.length) { final Point2i leftPos = new Point2i(Width, Height).sub(left[i]); pieces.add(new ParchmentPiece(leftPos, true, bg, pages.get(pageIndex))); pageIndex += 1;//from ww w.j ava 2 s.c o m } if (i < right.length) { final Point2i rightPos = new Point2i(0, Height).sub(right[i]); pieces.add(new ParchmentPiece(rightPos, false, bg, pages.get(pageIndex))); pageIndex += 1; } } for (ParchmentPiece piece : pieces) { piece.forceFinish(); } }
From source file:com.explatcreations.sft.graphics.TextSprite.java
License:Open Source License
public void setAlpha(float amount) { final Color oldColor = cache.getColor(); final Color newColor = new Color(oldColor.r, oldColor.g, oldColor.b, amount); cache.setColor(newColor);/*w w w. j av a 2 s.c o m*/ }
From source file:com.explatcreations.sft.gui.Panel.java
License:Open Source License
public Panel(IAction unset) { Game.assets.PageflipSound.play();/*from w w w. j av a 2s . c om*/ offset = new Point2i(0, MaxDistance); this.unset = unset; this.bg = new RectSprite(Game.RenderWidth, Game.RenderHeight, new Color(0, 0, 0, 0.73f)); this.frame = makePatch(false); frame.setPosition((Game.RenderWidth - frame.getWidth()) / 2 + getXOffset(), (Game.RenderHeight - frame.getHeight()) / 2 + getYOffset()); ParticleManager.suspend(); }
From source file:com.explatcreations.sft.gui.Patch.java
License:Open Source License
public Patch darken(float amount) { final Color color = new Color(amount, amount, amount, 1); for (int i = 0; i < cols; i += 1) { for (int j = 0; j < rows; j += 1) { sprites[i][j].setColor(color); }/* w w w.j a v a 2 s . c om*/ } return this; }
From source file:com.explatcreations.sft.modes.MenuButton.java
License:Open Source License
public MenuButton(LevelState levelState, LevelIndex levelIndex, float x, float y, IAction confirmCallback, IAction selectCallback) {// www.j a v a 2 s .c o m this.levelState = levelState; this.levelIndex = levelIndex; this.pos = new Point2i((int) x, (int) y); this.selectedText = NumberStamp.getWhiteSprite(levelIndex); this.isLocked = LevelState.Locked.eq(levelState); if (isLocked) { final TextSprite text = new TextSprite(0, 0, levelIndex.stageName()); text.setColor(new Color(0.53f, 0.53f, 0.53f, 1)); this.unselectedText = text; } else { this.unselectedText = NumberStamp.getBrownSprite(levelIndex); } final int xOffset = (Size - selectedText.getWidth()) / 2; this.textOffset = new Point2i(-2 + xOffset, 0); syncPosition(); final boolean isUnskippable = Game.save.isUnskippable(levelIndex); this.statusSprite = chooseStatusSprite(isUnskippable, levelState); this.confirmCallback = confirmCallback; this.selectCallback = selectCallback; }
From source file:com.explatcreations.sft.modes.title.TitleMode.java
License:Open Source License
public TitleMode() { if (Game.save.hasShownEnding(Ending.Mid)) { flagSprite = MidEndingWidget.makeFlagSprite(); flagSprite.play(MidEndingWidget.WavingName); }/*from w w w. j a va 2 s.c om*/ this.versionText = new TextSprite(2, 0, Game.globals.VersionString); versionText.y = Game.RenderHeight - 2 - versionText.getHeight(); versionText.setColor(Color.WHITE); this.flipTripLettering = Assets.makeSpriteFrame(letteringClass, letteringClass.getWidth(), letteringClass.getHeight(), 0); flipTripLettering.x = Game.RenderWidth / 2 - flipTripLettering.getWidth() / 2; flipTripLettering.y = 50; this.titleGraphic = Assets.makeSpriteFrame(titleClass, titleClass.getWidth(), titleClass.getHeight(), 0); this.sniffyLettering = new SniffyLetterCollection(); this.tower = Tower.makeTower(); this.shadow = Tower.makeShadow(); final Color skyColor = new Color(49f / 256, 19f / 256, 83f / 256, 1); this.skyGraphic = new RectSprite(Game.RenderWidth, Game.RenderHeight, skyColor); skyGraphic.y = -Height; this.floatyBits = new FloatingBitCollection(); this.stars = new StarCollection(); final int buttonX = Game.RenderWidth - 80; final int buttonY = Game.RenderHeight - 32; final IAction toMenu = new IAction() { @Override public void eval() { MusicManager.startFadeOut(60); Game.mode.transitionTo(new IFunction1<Mode>() { @Override public Mode apply() { BackgroundManager.start(); return new MenuMode(0); } }); } }; this.continueButton = new Button("Continue", buttonX, buttonY, toMenu, Controls.Enter); continueButton.setX(Game.RenderWidth - continueButton.getWidth() - 5); }
From source file:com.game.libgdx.roguelikeengine.PopupInfoText.java
License:Open Source License
public Color hex2Rgb(String colorStr) { return new Color(Integer.valueOf(colorStr.substring(1, 3), 16), Integer.valueOf(colorStr.substring(3, 5), 16), Integer.valueOf(colorStr.substring(5, 7), 16), 1f); }