List of usage examples for com.badlogic.gdx.graphics Color BLACK
Color BLACK
To view the source code for com.badlogic.gdx.graphics Color BLACK.
Click Source Link
From source file:th.skyousuke.libgdx.xomaisad.Assets.java
License:Apache License
public void init() { imageAtlas = new TextureAtlas(Gdx.files.internal("image.atlas")); font = new BitmapFont(Gdx.files.internal("font.fnt")); font.setColor(Color.BLACK); }
From source file:tilo.modules.graphics.java
License:Open Source License
public Color color(String name) { if (name.startsWith("#")) return Color.valueOf(name.replace("#", "")); if ("clear".equalsIgnoreCase(name)) return Color.CLEAR; else if ("white".equalsIgnoreCase(name)) return Color.WHITE; else if ("black".equalsIgnoreCase(name)) return Color.BLACK; else if ("red".equalsIgnoreCase(name)) return Color.RED; else if ("green".equalsIgnoreCase(name)) return Color.GREEN; else if ("blue".equalsIgnoreCase(name)) return Color.BLUE; else if ("lightgray".equalsIgnoreCase(name)) return Color.LIGHT_GRAY; else if ("gray".equalsIgnoreCase(name)) return Color.GRAY; else if ("darkgray".equalsIgnoreCase(name)) return Color.DARK_GRAY; else if ("pink".equalsIgnoreCase(name)) return Color.PINK; else if ("orange".equalsIgnoreCase(name)) return Color.ORANGE; else if ("yellow".equalsIgnoreCase(name)) return Color.YELLOW; else if ("magenta".equalsIgnoreCase(name)) return Color.MAGENTA; else if ("cyan".equalsIgnoreCase(name)) return Color.CYAN; return Color.CLEAR; }
From source file:us.thirdmillenium.strategicassaultsimulator.environment.GameEnvironment.java
License:Apache License
@Override public void simulate(float deltaTime) { // Compute time delta (max of frame speed) deltaTime = (float) Math.min(deltaTime, 1 / Params.FramesPerSecond); if (DRAW) {/*ww w . j a va 2 s.c o m*/ // Clear Background Gdx.gl.glClearColor(1, 0, 0, 1); Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); // Draw Map this.Camera.update(); this.TiledMapRenderer.setView(this.Camera); this.TiledMapRenderer.render(); } // Test if Bullets Intersected with Anything MapObjects wallMapObjects = this.TiledMap.getLayers().get(2).getObjects(); Iterator<GreenBullet> bullets = this.BulletTracker.iterator(); this.SpriteBatchRenderer.setProjectionMatrix(this.Camera.combined); this.SpriteBatchRenderer.begin(); while (bullets.hasNext()) { // Collect a Bullet to consider GreenBullet currentBullet = bullets.next(); if (DRAW) { currentBullet.drawSprite(this.SpriteBatchRenderer); } currentBullet.updateBullet(deltaTime); // If bullet is off-screen, remove it. if (currentBullet.getBulletVector().x < 0 || currentBullet.getBulletVector().x > this.width || currentBullet.getBulletVector().y < 0 || currentBullet.getBulletVector().y > this.height) { this.BulletTracker.remove(currentBullet); } else { // Compare with all Agents Rectangle agentBound; Iterator<AgentModel> shootItr = this.shooters.iterator(); while (shootItr.hasNext()) { AgentModel currShooter = shootItr.next(); if (!currentBullet.thisAgentShotMe(currShooter) && Intersector.overlapConvexPolygons( GraphicsHelpers.convertRectangleToPolygon(currShooter.getBoundingRectangle()), currentBullet.getBulletPath())) { currShooter.agentHit(); this.BulletTracker.remove(currentBullet); } } Iterator<AgentModel> agentItr = this.trainees.iterator(); while (agentItr.hasNext()) { AgentModel currAgent = agentItr.next(); if (!currentBullet.thisAgentShotMe(currAgent) && Intersector.overlapConvexPolygons( GraphicsHelpers.convertRectangleToPolygon(currAgent.getBoundingRectangle()), currentBullet.getBulletPath())) { currAgent.agentHit(); this.BulletTracker.remove(currentBullet); } } // Compare with all Wall Boundaries for (int i = 0; i < wallMapObjects.getCount(); i++) { Object rectangleMapObject = wallMapObjects.get(i); // Make sure this is a Rectangle from Tiled describing a wall. if (rectangleMapObject.getClass() == RectangleMapObject.class) { Rectangle wallRectangle = ((RectangleMapObject) rectangleMapObject).getRectangle(); Polygon polyBound = GraphicsHelpers.convertRectangleToPolygon(wallRectangle); // Terminate when hitting a wall if (Intersector.overlapConvexPolygons(polyBound, currentBullet.getBulletPath())) { this.BulletTracker.remove(currentBullet); } } } } } this.SpriteBatchRenderer.end(); // Draw DEBUG information if (DEBUG && DRAW) { // Draw Map Nodes /*this.MapNodeSR.setProjectionMatrix(this.Camera.combined); this.MapNodeSR.setColor(Color.OLIVE); this.MapNodeSR.begin(ShapeRenderer.ShapeType.Filled); if (this.TraverseNodes != null) { for (Integer key : this.TraverseNodes.keySet()) { this.MapNodeSR.circle(this.TraverseNodes.get(key).getPixelX(), this.TraverseNodes.get(key).getPixelY(), 10); } } this.MapNodeSR.end();*/ // Draw Overlay Lines this.LineRenderer.setProjectionMatrix(this.Camera.combined); this.LineRenderer.begin(ShapeRenderer.ShapeType.Filled); // For each Agent. Different Colors? this.LineRenderer.setColor(Color.BLACK); /*if( PUPPET ) { this.puppet.drawPath(this.LineRenderer); }*/ Iterator<AgentModel> agentItr = this.trainees.iterator(); while (agentItr.hasNext()) { AgentModel currAgent = agentItr.next(); currAgent.drawPath(this.LineRenderer); } this.LineRenderer.end(); } // Draw Agent Sprites this.SpriteBatchRenderer.begin(); /*if( PUPPET ) { this.puppet.updateAgent(deltaTime); this.puppet.drawAgent(this.SpriteBatchRenderer); }*/ Iterator<AgentModel> shootItr = this.shooters.iterator(); while (shootItr.hasNext()) { AgentModel currShooter = shootItr.next(); currShooter.updateAgent(deltaTime); if (DRAW) { currShooter.drawAgent(this.SpriteBatchRenderer); } } Iterator<AgentModel> agentItr = this.trainees.iterator(); while (agentItr.hasNext()) { AgentModel currAgent = agentItr.next(); currAgent.updateAgent(deltaTime); if (DRAW) { currAgent.drawAgent(this.SpriteBatchRenderer); } } this.SpriteBatchRenderer.end(); if (DEBUG) { Iterator<AgentModel> agentItr2 = this.trainees.iterator(); ShapeRenderer visionCone = new ShapeRenderer(); visionCone.setProjectionMatrix(this.Camera.combined); visionCone.begin(ShapeRenderer.ShapeType.Line); visionCone.setColor(Color.YELLOW); while (agentItr2.hasNext()) { AgentModel currAgent = agentItr2.next(); currAgent.drawVision(visionCone); } visionCone.end(); } /*// Test Draw the Collision Boxes if( DEBUG && DRAW ) { ShapeRenderer anotherShapeRenderer = new ShapeRenderer(); anotherShapeRenderer.setProjectionMatrix(this.Camera.combined); anotherShapeRenderer.begin(ShapeRenderer.ShapeType.Line); bullets = this.BulletTracker.iterator(); while(bullets.hasNext()) { GreenBullet currentBullet = bullets.next(); anotherShapeRenderer.polygon(currentBullet.getBulletPath().getTransformedVertices()); } for(int i = 0; i < wallMapObjects.getCount(); i++ ){ Object obj = wallMapObjects.get(i); if( obj.getClass() == RectangleMapObject.class ) { Rectangle boundary = ((RectangleMapObject)obj).getRectangle(); anotherShapeRenderer.rect(boundary.x, boundary.y, boundary.width, boundary.height); float[] vertices = { boundary.x, boundary.y, boundary.x + boundary.width, boundary.y, boundary.x + boundary.width, boundary.y + boundary.height, boundary.x, boundary.y + boundary.height }; //Polygon polyBound = new Polygon(vertices); anotherShapeRenderer.setColor(Color.BLUE); anotherShapeRenderer.polygon(vertices); } } anotherShapeRenderer.end(); }*/ }
From source file:ve.ucv.ciens.ccg.nxtar.graphics.shaders.DirectionalLightPerPixelShader.java
License:Apache License
@Override public void render(Renderable renderable) { ShaderProgram program;/* ww w.ja v a 2s .c o m*/ int index; boolean bonesEnabled; Vector3 lightPosition; Color diffuseLightColor; Color diffuseColor; Color specularColor; Color ambientColor; float shininess; // Get material colors. if (renderable.environment != null && renderable.environment.directionalLights != null && renderable.environment.directionalLights.size >= 1) { lightPosition = renderable.environment.directionalLights.get(0).direction; diffuseLightColor = renderable.environment.directionalLights.get(0).color; } else { lightPosition = DEFAULT_LIGHT; diffuseLightColor = Color.WHITE; } if (renderable.material.has(ColorAttribute.Diffuse)) diffuseColor = ((ColorAttribute) renderable.material.get(ColorAttribute.Diffuse)).color; else diffuseColor = Color.WHITE; if (renderable.material.has(ColorAttribute.Specular)) specularColor = ((ColorAttribute) renderable.material.get(ColorAttribute.Specular)).color; else specularColor = Color.BLACK; if (renderable.environment != null && renderable.environment.has(ColorAttribute.AmbientLight)) ambientColor = ((ColorAttribute) renderable.environment.get(ColorAttribute.AmbientLight)).color; else ambientColor = Color.BLACK; if (renderable.material.has(FloatAttribute.Shininess)) shininess = ((FloatAttribute) renderable.material.get(FloatAttribute.Shininess)).value; else shininess = DEFAULT_SHININESS; if (renderable.mesh.getVertexAttribute(VertexAttributes.Usage.BoneWeight) != null) { program = skinningProgram; index = 0; bonesEnabled = true; } else { program = baseProgram; index = 1; bonesEnabled = false; } program.begin(); // Set camera dependant uniforms. program.setUniformMatrix(u_projTrans[index], this.camera.combined); program.setUniformf(u_cameraPos[index], this.camera.position); // Set model dependant uniforms. program.setUniformMatrix(u_geomTrans[index], renderable.worldTransform); program.setUniformMatrix(u_normalMatrix[index], normalMatrix.set(renderable.worldTransform).toNormalMatrix()); program.setUniformf(u_lightPos[index], lightPosition); program.setUniformf(u_lightDiffuse[index], diffuseLightColor); program.setUniformf(u_materialDiffuse[index], diffuseColor); program.setUniformf(u_specular[index], specularColor); program.setUniformf(u_ambient[index], ambientColor); program.setUniformf(u_shiny[index], shininess); // Set the bones uniforms. if (bonesEnabled) { for (int i = 0; i < MAX_NUM_BONES; i++) { if (renderable.bones != null && i < renderable.bones.length && renderable.bones[i] != null) skinningProgram.setUniformMatrix(u_bones[i], renderable.bones[i]); else skinningProgram.setUniformMatrix(u_bones[i], IDENTITY); } } renderable.mesh.render(program, renderable.primitiveType, renderable.meshPartOffset, renderable.meshPartSize); program.end(); }
From source file:ve.ucv.ciens.ccg.nxtar.states.AutomaticActionState.java
License:Apache License
private void setUpButton() { TextButtonStyle textButtonStyle;//from ww w . j a va 2 s. co m FreeTypeFontGenerator fontGenerator; FreeTypeFontParameter fontParameters; // Create the start button background. startButtonEnabledTexture = new Texture( Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Yellow.png")); startButtonEnabled9p = new NinePatch(new TextureRegion(startButtonEnabledTexture, 0, 0, startButtonEnabledTexture.getWidth(), startButtonEnabledTexture.getHeight()), 49, 49, 45, 45); startButtonDisabledTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Cyan.png")); startButtonDisabled9p = new NinePatch(new TextureRegion(startButtonDisabledTexture, 0, 0, startButtonDisabledTexture.getWidth(), startButtonDisabledTexture.getHeight()), 49, 49, 45, 45); startButtonPressedTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Blue.png")); startButtonPressed9p = new NinePatch(new TextureRegion(startButtonPressedTexture, 0, 0, startButtonPressedTexture.getWidth(), startButtonPressedTexture.getHeight()), 49, 49, 45, 45); // Create the start button font. fontParameters = new FreeTypeFontParameter(); fontParameters.characters = ProjectConstants.FONT_CHARS; fontParameters.size = ProjectConstants.MENU_BUTTON_FONT_SIZE; fontParameters.flip = false; fontGenerator = new FreeTypeFontGenerator(Gdx.files.internal("data/fonts/d-puntillas-B-to-tiptoe.ttf")); font = fontGenerator.generateFont(fontParameters); fontGenerator.dispose(); // Create the start button. textButtonStyle = new TextButtonStyle(); textButtonStyle.font = font; textButtonStyle.up = new NinePatchDrawable(startButtonEnabled9p); textButtonStyle.checked = new NinePatchDrawable(startButtonPressed9p); textButtonStyle.disabled = new NinePatchDrawable(startButtonDisabled9p); textButtonStyle.fontColor = new Color(Color.BLACK); textButtonStyle.downFontColor = new Color(Color.WHITE); textButtonStyle.disabledFontColor = new Color(Color.BLACK); startButton = new TextButton("Start automatic action", textButtonStyle); startButton.setText("Start automatic action"); startButton.setDisabled(false); startButtonBBox = new Rectangle(0, 0, startButton.getWidth(), startButton.getHeight()); startButton.setPosition(-(startButton.getWidth() / 2), -(Gdx.graphics.getHeight() / 2) + 10); startButtonBBox.setPosition(startButton.getX(), startButton.getY()); // Set OUYA's O button. if (Ouya.runningOnOuya) { ouyaOButtonTexture = new Texture("data/gfx/gui/OUYA_O.png"); ouyaOButton = new Sprite(ouyaOButtonTexture); ouyaOButton.setSize(ouyaOButton.getWidth() * 0.6f, ouyaOButton.getHeight() * 0.6f); oButtonPressed = false; ouyaOButton.setPosition(startButton.getX() - ouyaOButton.getWidth() - 20, startButton.getY() + (ouyaOButton.getHeight() / 2)); } else { ouyaOButtonTexture = null; } }
From source file:ve.ucv.ciens.ccg.nxtar.states.AutomaticActionSummaryState.java
License:Apache License
public AutomaticActionSummaryState(NxtARCore core) throws IllegalArgumentException { TextButtonStyle textButtonStyle;/*from w w w.jav a 2 s . co m*/ FreeTypeFontGenerator fontGenerator; FreeTypeFontParameter fontParameters; NinePatch buttonEnabled9p; NinePatch buttonDisabled9p; NinePatch buttonPressed9p; if (core == null) throw new IllegalArgumentException(CLASS_NAME + ": Core is null."); this.core = core; this.pixelPerfectCamera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); oButtonPressed = false; automaticActionPerformer = ScenarioGlobals.getAutomaticActionPerformer(); summaryOverlay = ScenarioGlobals.getAutomaticActionSummaryOverlay(); // Create the start button background. buttonEnabledTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Yellow.png")); buttonEnabled9p = new NinePatch(new TextureRegion(buttonEnabledTexture, 0, 0, buttonEnabledTexture.getWidth(), buttonEnabledTexture.getHeight()), 49, 49, 45, 45); buttonDisabledTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Cyan.png")); buttonDisabled9p = new NinePatch(new TextureRegion(buttonDisabledTexture, 0, 0, buttonDisabledTexture.getWidth(), buttonDisabledTexture.getHeight()), 49, 49, 45, 45); buttonPressedTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Blue.png")); buttonPressed9p = new NinePatch(new TextureRegion(buttonPressedTexture, 0, 0, buttonPressedTexture.getWidth(), buttonPressedTexture.getHeight()), 49, 49, 45, 45); // Create the start button font. fontParameters = new FreeTypeFontParameter(); fontParameters.characters = ProjectConstants.FONT_CHARS; fontParameters.size = ProjectConstants.MENU_BUTTON_FONT_SIZE; fontParameters.flip = false; fontGenerator = new FreeTypeFontGenerator(Gdx.files.internal("data/fonts/d-puntillas-B-to-tiptoe.ttf")); font = fontGenerator.generateFont(fontParameters); fontGenerator.dispose(); // Create the contine button. textButtonStyle = new TextButtonStyle(); textButtonStyle.font = font; textButtonStyle.up = new NinePatchDrawable(buttonEnabled9p); textButtonStyle.checked = new NinePatchDrawable(buttonPressed9p); textButtonStyle.disabled = new NinePatchDrawable(buttonDisabled9p); textButtonStyle.fontColor = new Color(Color.BLACK); textButtonStyle.downFontColor = new Color(Color.WHITE); textButtonStyle.disabledFontColor = new Color(Color.BLACK); continueButton = new TextButton("Continue", textButtonStyle); continueButton.setText("Continue"); continueButton.setPosition(-(continueButton.getWidth() / 2), -(Utils.getScreenHeightWithOverscan() / 2) + 10); continueButtonBBox = new Rectangle(0, 0, continueButton.getWidth(), continueButton.getHeight()); continueButtonBBox.setPosition(continueButton.getX(), continueButton.getY()); // Set OUYA's O button. if (Ouya.runningOnOuya) { ouyaOButtonTexture = new Texture("data/gfx/gui/OUYA_O.png"); ouyaOButton = new Sprite(ouyaOButtonTexture); ouyaOButton.setSize(ouyaOButton.getWidth() * 0.6f, ouyaOButton.getHeight() * 0.6f); ouyaOButton.setPosition(continueButton.getX() - ouyaOButton.getWidth() - 20, continueButton.getY() + (ouyaOButton.getHeight() / 2)); oButtonPressed = false; } else { ouyaOButtonTexture = null; } // Set up the background. backgroundTexture = new Texture(Gdx.files.internal("data/gfx/textures/tile_aqua.png")); backgroundTexture.setWrap(TextureWrap.Repeat, TextureWrap.Repeat); backgroundTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); background = new Sprite(backgroundTexture); background.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); background.setPosition(-(Gdx.graphics.getWidth() / 2), -(Gdx.graphics.getHeight() / 2)); backgroundShader = new ShaderProgram(Gdx.files.internal(SHADER_PATH + "_vert.glsl"), Gdx.files.internal(SHADER_PATH + "_frag.glsl")); if (!backgroundShader.isCompiled()) { Gdx.app.error(TAG, CLASS_NAME + ".MainMenuStateBase() :: Failed to compile the background shader."); Gdx.app.error(TAG, CLASS_NAME + backgroundShader.getLog()); backgroundShader = null; } u_scaling = new float[2]; u_scaling[0] = Gdx.graphics.getWidth() > Gdx.graphics.getHeight() ? 16.0f : 9.0f; u_scaling[1] = Gdx.graphics.getHeight() > Gdx.graphics.getWidth() ? 16.0f : 9.0f; u_displacement = 1.0f; win2world = new Vector3(0.0f, 0.0f, 0.0f); touchPointWorldCoords = new Vector2(); continueButtonTouched = false; continueButtonTouchPointer = -1; stateActive = false; }
From source file:ve.ucv.ciens.ccg.nxtar.states.InstructionsState.java
License:Apache License
public InstructionsState(NxtARCore core) throws IllegalArgumentException { TextButtonStyle textButtonStyle;/*w w w. jav a 2 s. c o m*/ FreeTypeFontGenerator fontGenerator; FreeTypeFontParameter fontParameters; NinePatch buttonEnabled9p; NinePatch buttonDisabled9p; NinePatch buttonPressed9p; if (core == null) throw new IllegalArgumentException(CLASS_NAME + ": Core is null."); this.core = core; this.pixelPerfectCamera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); oButtonPressed = false; hintsOverlay = ScenarioGlobals.getHintsOverlay(); // Create the start button background. buttonEnabledTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Yellow.png")); buttonEnabled9p = new NinePatch(new TextureRegion(buttonEnabledTexture, 0, 0, buttonEnabledTexture.getWidth(), buttonEnabledTexture.getHeight()), 49, 49, 45, 45); buttonDisabledTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Cyan.png")); buttonDisabled9p = new NinePatch(new TextureRegion(buttonDisabledTexture, 0, 0, buttonDisabledTexture.getWidth(), buttonDisabledTexture.getHeight()), 49, 49, 45, 45); buttonPressedTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Blue.png")); buttonPressed9p = new NinePatch(new TextureRegion(buttonPressedTexture, 0, 0, buttonPressedTexture.getWidth(), buttonPressedTexture.getHeight()), 49, 49, 45, 45); // Create the start button font. fontParameters = new FreeTypeFontParameter(); fontParameters.characters = ProjectConstants.FONT_CHARS; fontParameters.size = ProjectConstants.MENU_BUTTON_FONT_SIZE; fontParameters.flip = false; fontGenerator = new FreeTypeFontGenerator(Gdx.files.internal("data/fonts/d-puntillas-B-to-tiptoe.ttf")); font = fontGenerator.generateFont(fontParameters); fontGenerator.dispose(); // Create the contine button. textButtonStyle = new TextButtonStyle(); textButtonStyle.font = font; textButtonStyle.up = new NinePatchDrawable(buttonEnabled9p); textButtonStyle.checked = new NinePatchDrawable(buttonPressed9p); textButtonStyle.disabled = new NinePatchDrawable(buttonDisabled9p); textButtonStyle.fontColor = new Color(Color.BLACK); textButtonStyle.downFontColor = new Color(Color.WHITE); textButtonStyle.disabledFontColor = new Color(Color.BLACK); continueButton = new TextButton("Continue", textButtonStyle); continueButton.setText("Continue"); continueButton.setPosition(-(continueButton.getWidth() / 2), -(Utils.getScreenHeightWithOverscan() / 2) + 10); continueButtonBBox = new Rectangle(0, 0, continueButton.getWidth(), continueButton.getHeight()); continueButtonBBox.setPosition(continueButton.getX(), continueButton.getY()); // Set OUYA's O button. if (Ouya.runningOnOuya) { ouyaOButtonTexture = new Texture("data/gfx/gui/OUYA_O.png"); ouyaOButton = new Sprite(ouyaOButtonTexture); ouyaOButton.setSize(ouyaOButton.getWidth() * 0.6f, ouyaOButton.getHeight() * 0.6f); ouyaOButton.setPosition(continueButton.getX() - ouyaOButton.getWidth() - 20, continueButton.getY() + (ouyaOButton.getHeight() / 2)); oButtonPressed = false; } else { ouyaOButtonTexture = null; } // Set up the background. backgroundTexture = new Texture(Gdx.files.internal("data/gfx/textures/tile_aqua.png")); backgroundTexture.setWrap(TextureWrap.Repeat, TextureWrap.Repeat); backgroundTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); background = new Sprite(backgroundTexture); background.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); background.setPosition(-(Gdx.graphics.getWidth() / 2), -(Gdx.graphics.getHeight() / 2)); backgroundShader = new ShaderProgram(Gdx.files.internal(SHADER_PATH + "_vert.glsl"), Gdx.files.internal(SHADER_PATH + "_frag.glsl")); if (!backgroundShader.isCompiled()) { Gdx.app.error(TAG, CLASS_NAME + ".MainMenuStateBase() :: Failed to compile the background shader."); Gdx.app.error(TAG, CLASS_NAME + backgroundShader.getLog()); backgroundShader = null; } u_scaling = new float[2]; u_scaling[0] = Gdx.graphics.getWidth() > Gdx.graphics.getHeight() ? 16.0f : 9.0f; u_scaling[1] = Gdx.graphics.getHeight() > Gdx.graphics.getWidth() ? 16.0f : 9.0f; u_displacement = 1.0f; win2world = new Vector3(0.0f, 0.0f, 0.0f); touchPointWorldCoords = new Vector2(); continueButtonTouched = false; continueButtonTouchPointer = -1; stateActive = false; }
From source file:ve.ucv.ciens.ccg.nxtar.states.MainMenuStateBase.java
License:Apache License
public MainMenuStateBase() { TextureRegion region;/*w w w . j a va 2 s . c o m*/ TextButtonStyle textButtonStyle; FreeTypeFontGenerator fontGenerator; FreeTypeFontParameter fontParameters; this.pixelPerfectCamera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); // Create the start button background. menuButtonEnabledTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Yellow.png")); menuButtonEnabled9p = new NinePatch(new TextureRegion(menuButtonEnabledTexture, 0, 0, menuButtonEnabledTexture.getWidth(), menuButtonEnabledTexture.getHeight()), 49, 49, 45, 45); menuButtonDisabledTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Cyan.png")); menuButtonDisabled9p = new NinePatch(new TextureRegion(menuButtonDisabledTexture, 0, 0, menuButtonDisabledTexture.getWidth(), menuButtonDisabledTexture.getHeight()), 49, 49, 45, 45); menuButtonPressedTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Blue.png")); menuButtonPressed9p = new NinePatch(new TextureRegion(menuButtonPressedTexture, 0, 0, menuButtonPressedTexture.getWidth(), menuButtonPressedTexture.getHeight()), 49, 49, 45, 45); // Create the start button font. fontParameters = new FreeTypeFontParameter(); fontParameters.characters = ProjectConstants.FONT_CHARS; fontParameters.size = ProjectConstants.MENU_BUTTON_FONT_SIZE; fontParameters.flip = false; fontGenerator = new FreeTypeFontGenerator(Gdx.files.internal("data/fonts/d-puntillas-B-to-tiptoe.ttf")); font = fontGenerator.generateFont(fontParameters); fontGenerator.dispose(); // Create the buttons. textButtonStyle = new TextButtonStyle(); textButtonStyle.font = font; textButtonStyle.up = new NinePatchDrawable(menuButtonEnabled9p); textButtonStyle.checked = new NinePatchDrawable(menuButtonPressed9p); textButtonStyle.disabled = new NinePatchDrawable(menuButtonDisabled9p); textButtonStyle.fontColor = new Color(Color.BLACK); textButtonStyle.downFontColor = new Color(Color.WHITE); textButtonStyle.disabledFontColor = new Color(Color.BLACK); startButton = new TextButton("Manual control", textButtonStyle); startButton.setText("Manual control"); startButton.setDisabled(true); startButtonBBox = new Rectangle(0, 0, startButton.getWidth(), startButton.getHeight()); calibrationButton = new TextButton("Calibrate camera", textButtonStyle); calibrationButton.setText("Calibrate camera"); calibrationButton.setDisabled(true); calibrationButtonBBox = new Rectangle(0, 0, calibrationButton.getWidth(), calibrationButton.getHeight()); autoButton = new TextButton("Automatic action", textButtonStyle); autoButton.setText("Automatic action"); autoButton.setDisabled(true); autoButtonBBox = new Rectangle(0, 0, autoButton.getWidth(), autoButton.getHeight()); // Create the connection leds. ledOnTexture = new Texture("data/gfx/gui/Anonymous_Button_Green.png"); ledOffTexture = new Texture("data/gfx/gui/Anonymous_Button_Red.png"); region = new TextureRegion(ledOnTexture); cameraCalibratedLedOn = new Sprite(region); region = new TextureRegion(ledOffTexture); cameraCalibratedLedOff = new Sprite(region); region = new TextureRegion(ledOnTexture); assetsLoadedLedOn = new Sprite(region); region = new TextureRegion(ledOffTexture); assetsLoadedLedOff = new Sprite(region); // Set up the background. backgroundTexture = new Texture(Gdx.files.internal("data/gfx/textures/tile_aqua.png")); backgroundTexture.setWrap(TextureWrap.Repeat, TextureWrap.Repeat); backgroundTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); region = new TextureRegion(backgroundTexture); background = new Sprite(backgroundTexture); background.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); background.setPosition(-(Gdx.graphics.getWidth() / 2), -(Gdx.graphics.getHeight() / 2)); backgroundShader = new ShaderProgram(Gdx.files.internal(SHADER_PATH + "_vert.glsl"), Gdx.files.internal(SHADER_PATH + "_frag.glsl")); if (!backgroundShader.isCompiled()) { Gdx.app.error(TAG, CLASS_NAME + ".MainMenuStateBase() :: Failed to compile the background shader."); Gdx.app.error(TAG, CLASS_NAME + backgroundShader.getLog()); backgroundShader = null; } u_scaling = new float[2]; u_scaling[0] = Gdx.graphics.getWidth() > Gdx.graphics.getHeight() ? 16.0f : 9.0f; u_scaling[1] = Gdx.graphics.getHeight() > Gdx.graphics.getWidth() ? 16.0f : 9.0f; u_displacement = 1.0f; win2world = new Vector3(0.0f, 0.0f, 0.0f); touchPointWorldCoords = new Vector2(); startButtonTouched = false; startButtonTouchPointer = -1; calibrationButtonTouched = false; calibrationButtonTouchPointer = -1; autoButtonTouched = false; autoButtonTouchPointer = -1; clientConnected = false; cameraCalibrated = false; assetsLoaded = false; stateActive = false; }
From source file:ve.ucv.ciens.ccg.nxtar.states.ScenarioEndSummaryState.java
License:Apache License
public ScenarioEndSummaryState(NxtARCore core) throws IllegalArgumentException { TextButtonStyle textButtonStyle;//from www .j a va 2 s .c om FreeTypeFontGenerator fontGenerator; FreeTypeFontParameter fontParameters; NinePatch buttonEnabled9p; NinePatch buttonDisabled9p; NinePatch buttonPressed9p; if (core == null) throw new IllegalArgumentException(CLASS_NAME + ": Core is null."); this.core = core; this.pixelPerfectCamera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); oButtonPressed = false; playerSystem = ScenarioGlobals.getPlayerSystem(); summaryOverlay = ScenarioGlobals.getScenarioSummaryOverlay(); // Create the start button background. buttonEnabledTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Yellow.png")); buttonEnabled9p = new NinePatch(new TextureRegion(buttonEnabledTexture, 0, 0, buttonEnabledTexture.getWidth(), buttonEnabledTexture.getHeight()), 49, 49, 45, 45); buttonDisabledTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Cyan.png")); buttonDisabled9p = new NinePatch(new TextureRegion(buttonDisabledTexture, 0, 0, buttonDisabledTexture.getWidth(), buttonDisabledTexture.getHeight()), 49, 49, 45, 45); buttonPressedTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Blue.png")); buttonPressed9p = new NinePatch(new TextureRegion(buttonPressedTexture, 0, 0, buttonPressedTexture.getWidth(), buttonPressedTexture.getHeight()), 49, 49, 45, 45); // Create the start button font. fontParameters = new FreeTypeFontParameter(); fontParameters.characters = ProjectConstants.FONT_CHARS; fontParameters.size = ProjectConstants.MENU_BUTTON_FONT_SIZE; fontParameters.flip = false; fontGenerator = new FreeTypeFontGenerator(Gdx.files.internal("data/fonts/d-puntillas-B-to-tiptoe.ttf")); font = fontGenerator.generateFont(fontParameters); fontGenerator.dispose(); // Create the contine button. textButtonStyle = new TextButtonStyle(); textButtonStyle.font = font; textButtonStyle.up = new NinePatchDrawable(buttonEnabled9p); textButtonStyle.checked = new NinePatchDrawable(buttonPressed9p); textButtonStyle.disabled = new NinePatchDrawable(buttonDisabled9p); textButtonStyle.fontColor = new Color(Color.BLACK); textButtonStyle.downFontColor = new Color(Color.WHITE); textButtonStyle.disabledFontColor = new Color(Color.BLACK); continueButton = new TextButton("Continue", textButtonStyle); continueButton.setText("Continue"); continueButton.setPosition(-(continueButton.getWidth() / 2), -(Utils.getScreenHeightWithOverscan() / 2) + 10); continueButtonBBox = new Rectangle(0, 0, continueButton.getWidth(), continueButton.getHeight()); continueButtonBBox.setPosition(continueButton.getX(), continueButton.getY()); // Set OUYA's O button. if (Ouya.runningOnOuya) { ouyaOButtonTexture = new Texture("data/gfx/gui/OUYA_O.png"); ouyaOButton = new Sprite(ouyaOButtonTexture); ouyaOButton.setSize(ouyaOButton.getWidth() * 0.6f, ouyaOButton.getHeight() * 0.6f); ouyaOButton.setPosition(continueButton.getX() - ouyaOButton.getWidth() - 20, continueButton.getY() + (ouyaOButton.getHeight() / 2)); oButtonPressed = false; } else { ouyaOButtonTexture = null; } // Set up the background. backgroundTexture = new Texture(Gdx.files.internal("data/gfx/textures/tile_aqua.png")); backgroundTexture.setWrap(TextureWrap.Repeat, TextureWrap.Repeat); backgroundTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); background = new Sprite(backgroundTexture); background.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); background.setPosition(-(Gdx.graphics.getWidth() / 2), -(Gdx.graphics.getHeight() / 2)); backgroundShader = new ShaderProgram(Gdx.files.internal(SHADER_PATH + "_vert.glsl"), Gdx.files.internal(SHADER_PATH + "_frag.glsl")); if (!backgroundShader.isCompiled()) { Gdx.app.error(TAG, CLASS_NAME + ".MainMenuStateBase() :: Failed to compile the background shader."); Gdx.app.error(TAG, CLASS_NAME + backgroundShader.getLog()); backgroundShader = null; } u_scaling = new float[2]; u_scaling[0] = Gdx.graphics.getWidth() > Gdx.graphics.getHeight() ? 16.0f : 9.0f; u_scaling[1] = Gdx.graphics.getHeight() > Gdx.graphics.getWidth() ? 16.0f : 9.0f; u_displacement = 1.0f; win2world = new Vector3(0.0f, 0.0f, 0.0f); touchPointWorldCoords = new Vector2(); continueButtonTouched = false; continueButtonTouchPointer = -1; stateActive = false; }
From source file:YOGOSec.core.gui.Button.java
License:LGPL
public Button(Rectanglef bounds, String text, IActionListener listener) { super(bounds); this.text = text; this.listener = listener; this.pixmap = new YUpPixmap(Game.INSTANCE.getRender().getWidth(), Game.INSTANCE.getRender().getHeight(), Pixmap.Format.RGBA8888); pixmap.setColor(Color.RED);/*w w w. j a va 2 s . com*/ pixmap.fillRectangle(this.bounds.getX().intValue(), this.bounds.getY().intValue(), this.bounds.getWidth().intValue(), this.bounds.getHeight().intValue()); pixmap.setColor(Color.BLACK); Gdx.app.log("YOGOSec", "Created button: " + this.bounds); this.texture = new Texture(this.pixmap); }