Java Code Examples for com.badlogic.gdx.Gdx

The following are top voted examples for showing how to use com.badlogic.gdx.Gdx. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: enklave   File: ScreenChat.java   Source Code and License 7 votes vote down vote up
public void Addtogroup(){
    grchatfaction = new VerticalGroup();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd/HH:mm:ss");
    try {
        grchatfaction.addActor(addComment(sdf.parse("2016/5/17/13:34:23"),"adrian", Color.BLUE,"Welcome Chat!"));
        grchatfaction.addActor(addComment(sdf.parse("2016/5/17/13:34:23"),"adrian", Color.BLUE,"Faction!"));
        grchatfaction.addActor(labelTest1);
    } catch (ParseException e) {
        e.printStackTrace();
        Gdx.app.log("eroare","intra");
    }
    sp = new ScrollPane(grchatfaction);
    sp.layout();
    sp.setScrollingDisabled(true, false);
    sp.setFillParent(true);sp.setLayoutEnabled(true);
    ta = new Table();
    ta.setFillParent(false);
    ta.add(sp).fill().expand();
    ta.setBounds(WIDTH *0.05f,background1.getY(), WIDTH*0.9f,background1.getHeight() * 1.05f);
    ta.setVisible(false);
    groupbotttom.addActor(ta);
    sp.setScrollPercentY(200);
    sp.act(Gdx.graphics.getDeltaTime());
    sp.updateVisualScroll();
}
 
Example 2
Project: Klooni1010   File: VanishEffect.java   Source Code and License 6 votes vote down vote up
@Override
public void draw(Batch batch) {
    vanishElapsed += Gdx.graphics.getDeltaTime();

    // vanishElapsed might be < 0 (delay), so clamp to 0
    float progress = Math.min(1f,
            Math.max(vanishElapsed, 0f) / vanishLifetime);

    // If one were to plot the elasticIn function, they would see that the slope increases
    // a lot towards the end- a linear interpolation between the last size + the desired
    // size at 20% seems to look a lot better.
    vanishSize = MathUtils.lerp(
            vanishSize,
            Interpolation.elasticIn.apply(cell.size, 0, progress),
            0.2f
    );

    float centerOffset = cell.size * 0.5f - vanishSize * 0.5f;
    Cell.draw(vanishColor, batch, cell.pos.x + centerOffset, cell.pos.y + centerOffset, vanishSize);
}
 
Example 3
Project: drc-sim-client   File: StageLoad.java   Source Code and License 6 votes vote down vote up
/**
 * Loading stage
 * @param doLoad should resources be loaded? It acts as a splash screen otherwise.
 */
public StageLoad(boolean doLoad) {
	this.doLoad = doLoad;
	// Create icon
	icon = new Image(new Texture("image/icon-512.png"));
	int size = Gdx.graphics.getHeight();
	if (Gdx.graphics.getHeight() > Gdx.graphics.getWidth())
		size = Gdx.graphics.getWidth();
	icon.setSize(size, size);
	icon.setPosition(Gdx.graphics.getWidth() / 2 - size / 2,
			Gdx.graphics.getHeight() / 2 - icon.getHeight() / 2);
	addActor(icon);
	// Loading Text
	Label.LabelStyle loadingStyle = new Label.LabelStyle();
	loadingStyle.font = new BitmapFont(Gdx.files.internal("font/collvetica.fnt"));
	loadingStyle.font.getData().setScale(Gdx.graphics.getHeight() * 2 / 720);
	loading = new Label("DRC Sim", loadingStyle);
	loading.setBounds(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight() * .2f);
	loading.setAlignment(Align.center);
	addActor(loading);
}
 
Example 4
Project: enklave   File: ScreenChat.java   Source Code and License 6 votes vote down vote up
public void addchatlocation(){
    grchatlocation = new VerticalGroup();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd/HH:mm:ss");
    try {
        grchatlocation.addActor(addComment(sdf.parse("2016/5/17/13:34:23"),"adrian", Color.RED,"Welcome Chat!"));
        grchatlocation.addActor(addComment(sdf.parse("2016/5/17/13:34:23"),"adrian", Color.GREEN,"Location!"));
        grchatlocation.addActor(labelTest);
    } catch (ParseException e) {
        e.printStackTrace();
        Gdx.app.log("eroare","intra");
    }
    scrollchatpublic = new ScrollPane(grchatlocation);
    scrollchatpublic.layout();
    scrollchatpublic.setScrollingDisabled(true, false);
    scrollchatpublic.setFillParent(true);
    scrollchatpublic.setLayoutEnabled(true);
    tablechatpublic = new Table();
    tablechatpublic.setFillParent(false);
    tablechatpublic.add(scrollchatpublic).fill().expand();
    tablechatpublic.setBounds(WIDTH *0.05f,background1.getY(), WIDTH*0.9f,background1.getHeight() * 1.05f);
    groupbotttom.addActor(tablechatpublic);
    scrollchatpublic.setScrollPercentY(100);
    scrollchatpublic.act(Gdx.graphics.getDeltaTime());
    scrollchatpublic.updateVisualScroll();
}
 
Example 5
Project: ProjektGG   File: BaseUIScreen.java   Source Code and License 6 votes vote down vote up
@Override
public void render(float delta) {
	Gdx.gl.glClearColor(backgroundColor.r, backgroundColor.g,
			backgroundColor.b, backgroundColor.a);
	Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

	game.getSpriteBatch().begin();

	if (backgroundTexture != null)
		game.getSpriteBatch().draw(this.backgroundTexture, 0, 0,
				game.getViewportWidth(), game.getViewportHeight());

	game.getSpriteBatch().setProjectionMatrix(game.getUICamera().combined);

	stage.act(delta);
	stage.draw();

	game.getSpriteBatch().end();
}
 
Example 6
Project: ProjektGG   File: ScreenshotUtils.java   Source Code and License 6 votes vote down vote up
public static void takeScreenshot() {
	byte[] pixels = ScreenUtils.getFrameBufferPixels(0, 0,
			Gdx.graphics.getBackBufferWidth(),
			Gdx.graphics.getBackBufferHeight(), true);

	Pixmap pixmap = new Pixmap(Gdx.graphics.getBackBufferWidth(),
			Gdx.graphics.getBackBufferHeight(), Pixmap.Format.RGBA8888);
	BufferUtils.copy(pixels, 0, pixmap.getPixels(), pixels.length);

	SimpleDateFormat dateFormat = new SimpleDateFormat(
			"yyyy-MM-dd HH-mm-ss");

	PixmapIO.writePNG(
			Gdx.files.external(dateFormat.format(new Date()) + ".png"),
			pixmap);
	pixmap.dispose();
}
 
Example 7
Project: Klooni1010   File: PauseMenuStage.java   Source Code and License 6 votes vote down vote up
@Override
public void draw() {
    if (shown) {
        // Draw an overlay rectangle with not all the opacity
        // This is the only place where ShapeRenderer is OK because the batch hasn't started
        Gdx.gl.glEnable(GL20.GL_BLEND);
        shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
        Color color = new Color(Klooni.theme.bandColor);
        color.a = 0.1f;
        shapeRenderer.setColor(color);
        shapeRenderer.rect(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
        shapeRenderer.end();
    }

    super.draw();
}
 
Example 8
Project: Tower-Defense-Galaxy   File: FileHandler.java   Source Code and License 6 votes vote down vote up
public static List<Spawn> loadSpawns(BufferedReader data) {
    if (data == null)
        return null;
    List<Spawn> spawns = new ArrayList<com.logicmaster63.tdgalaxy.map.Spawn>();
    try {
        int spawnNum = Integer.parseInt(data.readLine());
        for (int i = 0; i < spawnNum; i++) {
            int repeatNum = Integer.parseInt(data.readLine());
            String name = data.readLine();
            int delay = Integer.parseInt(data.readLine());
            for (int j = 0; j < repeatNum; j++)
                spawns.add(new Spawn(name, delay));
            data.close();
        }
    } catch (IOException e) {
        Gdx.app.error("Error", e.toString());
    }
    return spawns;
}
 
Example 9
Project: Cubes_2   File: DedicatedServer.java   Source Code and License 6 votes vote down vote up
private static Save getSave(CubesCmdLineOptions.ServerCmdLineOptions options) {
	FileHandle worldFolder = Compatibility.get().getBaseFolder().child("world");
	if (options.worldFolder != null)
		worldFolder = Gdx.files.absolute(options.worldFolder);
	Save save = new Save("world", worldFolder);
	if (save.readSaveOptions() == null) {
		SaveOptions saveOptions = save.getSaveOptions();
		if (options.worldSeedString != null)
			saveOptions.setWorldSeed(options.worldSeedString);
		if (options.worldGenerator != null)
			saveOptions.worldType = options.worldGenerator;
		if (options.worldGamemode != null)
			saveOptions.worldGamemode = options.worldGamemode;
	}
	return save;
}
 
Example 10
Project: Flappy-Baranus   File: GameOver.java   Source Code and License 6 votes vote down vote up
public GameOver(GameStateManager gsm, int score) {
    super(gsm);
    this.score = score;
    camera.setToOrtho(false, FlappyBaran.WIDTH / 2, FlappyBaran.HEIGHT / 2);
    background = new Texture("backgrnd.jpg");
    gameover = new Texture("gameover.png");
    font = new BitmapFont();
    prefs = Gdx.app.getPreferences("FlappyBaran");

    if (!prefs.contains("highScore")) {
        prefs.putInteger("highScore", 0);
    }

    prevHighScore = getHighScore();

    if (prevHighScore < this.score) {
        setHighScore(this.score);
        highscore = this.score;
    } else {
        highscore = prevHighScore;
    }

}
 
Example 11
Project: NoRiskNoFun   File: LobbyScene.java   Source Code and License 6 votes vote down vote up
private void initImageButtons() {

        if (!sceneData.isGameHost()) {
            return; // player is not hosting - don't offer the player to start the game.
        }

        imageButtonStartGame = new ImageButtonSceneObject(sceneData.createImageButton(Assets.START_GAME_BUTTON_FILENAME), buttonPressedSound);
        imageButtonStartGame.setBounds((Gdx.graphics.getWidth() / 2.0f) - 137.5f, Gdx.graphics.getHeight() / 10.0f, 275f, 240f);
        imageButtonStartGame.addListener(new ClickListener() {
            @Override
            public void clicked(InputEvent event, float x, float y) {
                sceneData.sendMessageFromGui(new StartGameClicked());
            }
        });
        addSceneObject(imageButtonStartGame);
        imageButtonStartGame.setDisabled();
    }
 
Example 12
Project: NoRiskNoFun   File: ClientConnectedState.java   Source Code and License 6 votes vote down vote up
@Override
public void handleOutboundMessage(Message message) {

    if (message instanceof DisconnectClient) {
        handleDisconnect(((DisconnectClient)message).isTerminateClient());
        return;
    }

    try {
        byte[] data = new MessageSerializer(message).serialize();
        write(data);
    } catch (IOException | ProtocolException e) {
        Gdx.app.error(getClass().getSimpleName(), "Handling outbound message failed", e);
        handleDisconnect(true);
    }
}
 
Example 13
Project: enklave   File: ProgressBarEnergy.java   Source Code and License 6 votes vote down vote up
public void downenergy(int value){
    bar.act(Gdx.graphics.getDeltaTime());
    infoProfile.getDateUserGame().setEnergy(infoProfile.getDateUserGame().getEnergy() - value);
    FadeIn();
    new Timer().schedule(new Timer.Task() {
        @Override
        public void run() {
            bar.setAnimateDuration(3);
            bar.setValue((float) infoProfile.getDateUserGame().getEnergy());
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            mapsScreen.startTimer();
        }
    }, 1000);
}
 
Example 14
Project: NoRiskNoFun   File: WaitingForNextTurnState.java   Source Code and License 6 votes vote down vote up
@Override
public void handleMessage(String senderId, Message message) {
    if(message.getType().equals(NextPlayer.class)){
        setNextPlayer(((NextPlayer)message).getPlayername());
    } else if (message.getType().equals(IsAttacked.class)) {
        context.setState(new AttackState(context, false));
    } else if (message.getType().equals(AttackResult.class)) { // react on broadcast attack result as we have to update the regions
        updateRegions((AttackResult)message);
    } else if (message.getType().equals(SpawnTroop.class)) {
        doSpawnTroop((SpawnTroop) message);
    } else if (message.getType().equals(MoveTroop.class)) {
        doMoveTroop((MoveTroop) message);
    }
    else{
        Gdx.app.log("WaitingForNextTurnState","unknown messgae:"+message.getType().getSimpleName());
    }
}
 
Example 15
Project: enklave   File: ScreenRooms.java   Source Code and License 6 votes vote down vote up
@Override
    public void show() {
        if(drawone){
            addroomselect();
            addButtonBottom();
            addPuls();
            addimagebg();
            addbuildRoom();
            addtimerbuildroom();
            drawone = false;
        }
        cameraGroupStrategy = new CameraGroupStrategy(camera);
//        CameraInputController controller = new CameraInputController(camera);
        stage = new Stage(new StretchViewport(Gdx.graphics.getWidth(),Gdx.graphics.getHeight()));
        batchsprite = new SpriteBatch();
        addtostage();
        batch = new DecalBatch(this.cameraGroupStrategy);
        Gdx.input.setCatchBackKey(true);
        InputMultiplexer inputmulti = new InputMultiplexer();
        inputmulti.addProcessor(stage);
        Gdx.input.setInputProcessor(inputmulti);
    }
 
Example 16
Project: Cubes_2   File: AssetFinder.java   Source Code and License 6 votes vote down vote up
private static void extractAssets(URL jar, AssetManager assetManager) {
	String assets = "assets";
	try {
		ZipInputStream zip = new ZipInputStream(getInputStream(jar));
		ZipEntry ze = zip.getNextEntry();
		while (ze != null) {
			String name = ze.getName().replace("\\", "/");
			if (name.startsWith(assets) && !ze.isDirectory()) {
				name = name.substring(ze.getName().lastIndexOf(assets) + assets.length() + 1);
				assetManager.assets.put(name, new Asset(assetManager, name, Gdx.files.internal(ze.getName())));
			}
			ze = zip.getNextEntry();
		}
		zip.close();
	} catch (Exception e) {
		Log.error("Failed to extract assets", e);
	}
}
 
Example 17
Project: gdx-gamesvcs   File: GpgsClient.java   Source Code and License 6 votes vote down vote up
public boolean connect(boolean autoStart) {
    if (mGoogleApiClient == null) {
        Gdx.app.error(GAMESERVICE_ID, "Call initialize first.");
        throw new IllegalStateException();
    }

    if (isSessionActive())
        return true;

    Gdx.app.log(GAMESERVICE_ID, "Trying to connect with autostart " + autoStart);
    mAutoStartSignInflow = autoStart;
    mSignInClicked = !autoStart;
    isConnectionPending = true;
    mGoogleApiClient.connect();

    return true;
}
 
Example 18
Project: feup-lpoo-armadillo   File: LevelMenuScreen.java   Source Code and License 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void show() {
    super.show();

    // Table containing the Level Buttons
    Table levels = new Table();
    levels.top();
    levels.padTop(TOP_EDGE);
    createLevelButtons(levels);

    // Table containing the Static Elements
    Table staticElements = new Table();
    staticElements.setFillParent(true);
    createStaticElements(staticElements, levels);

    stage.addActor(staticElements);
    Gdx.input.setInputProcessor(stage);
}
 
Example 19
Project: school-game   File: AudioManager.java   Source Code and License 6 votes vote down vote up
/**
 * Erstellt einen Sound in der Sound-Datenbank und lädt ihn.
 *
 * @see AudioManager#createSound(String, String)
 * @see AudioManager#unloadSound(SoundKey)
 * @see AudioManager#playSound(SoundKey)
 * @see AudioManager#playSound(SoundKey, float)
 *
 * @param group zu welcher Gruppe gehört der Sound?
 * @param name der Name der Sounddatei mit Endung
 * @param autoUnload true damit der Sound beim Beenden ohne Warnung entladen wird. Sparsam benutzen.
 * @return ein Verweis auf den Sound der zum Abspielen benutzt werden kann
 */
public SoundKey createSound(String group, String name, boolean autoUnload)
{
    String soundId = group + "/" +name;

    if (soundMap.containsKey(soundId))
        return new SoundKey(soundId);

    Sound sound = Gdx.audio.newSound(Gdx.files.internal("data/sound/" + soundId));
    soundMap.put(soundId, sound);

    SoundKey soundKey = new SoundKey(soundId);

    if (autoUnload)
        autoUnloadSounds.add(soundKey);

    return soundKey;
}
 
Example 20
Project: gdx-gamesvcs   File: GameJoltClient.java   Source Code and License 6 votes vote down vote up
protected void sendOpenSessionEvent() {
    if (!isSessionActive())
        return;

    Map<String, String> params = new HashMap<String, String>();
    addGameIDUserNameUserToken(params);

    final Net.HttpRequest http = buildJsonRequest("sessions/open/", params);

    if (http != null)
        Gdx.net.sendHttpRequest(http, new NoOpResponseListener());

    pingTask = Timer.schedule(new Timer.Task() {
        @Override
        public void run() {
            sendKeepSessionOpenEvent();
        }
    }, GJ_PING_INTERVAL, GJ_PING_INTERVAL);

}
 
Example 21
Project: enklave   File: ScreenCombat.java   Source Code and License 6 votes vote down vote up
private void drawdefenders(){
    defenders = new DrawDefenders();
    groupBtnDefender = new Group();
    Button btn1 = new Button(new ImageButton.ImageButtonStyle());
    btn1.setName("btn1");
    btn1.setSize(Gdx.graphics.getWidth() * 0.18f, Gdx.graphics.getWidth() * 0.2f);
    btn1.setPosition(Gdx.graphics.getWidth() * 0.025f, Gdx.graphics.getHeight() / 2.3f - Gdx.graphics.getHeight() * 0.14f);
    groupBtnDefender.addActor(btn1);
    Button btn2 = new Button(new ImageButton.ImageButtonStyle());
    btn2.setName("btn2");
    btn2.setSize(Gdx.graphics.getWidth() * 0.18f, Gdx.graphics.getWidth() * 0.2f);
    btn2.setPosition(Gdx.graphics.getWidth() * 0.025f, Gdx.graphics.getHeight() / 2.3f);
    groupBtnDefender.addActor(btn2);
    Button btn3 = new Button(new ImageButton.ImageButtonStyle());
    btn3.setName("btn3");
    btn3.setSize(Gdx.graphics.getWidth() * 0.18f, Gdx.graphics.getWidth() * 0.2f);
    btn3.setPosition(Gdx.graphics.getWidth() * 0.025f, Gdx.graphics.getHeight() / 2.3f + Gdx.graphics.getHeight() * 0.14f);
    groupBtnDefender.addActor(btn3);
}
 
Example 22
Project: Parasites-of-HellSpace   File: Rocket.java   Source Code and License 6 votes vote down vote up
@Override
public void update(Player player)
{
    posY -= speed * Gdx.graphics.getDeltaTime();
    sprite.setPosition(posX, posY);
    lifeTime--;
    flashLTime--;

    if(lifeTime < 0)
        alive = false;
    if(flashLTime < 0)
        stopRenderFlash = true;

    if(player != null && SIUtils.intersectsWith(this.sprite, player.getSprite()))
    {
        this.alive = false;
        if(!player.isGodMode())
            player.setHealth(player.getHealth() - damage);
    }
}
 
Example 23
Project: summer17-android   File: Level1.java   Source Code and License 6 votes vote down vote up
@Override
protected void handleInput() {
    if (Gdx.input.justTouched()) {
        if (a == 1) {
            sheep.jump();
        }
        if (a == 2) {
            cow.jump();
        }
        if (a == 3) {
            pig.jump();
        }
        if (a == 4) {
            bunny.jump();
        }
        if (a == 5) {
            chick.jump();
        }
    }
}
 
Example 24
Project: NoRiskNoFun   File: LibGdxAssetCache.java   Source Code and License 5 votes vote down vote up
/**
 * Generate new bitmap font.
 *
 * @param fontDescriptor Descriptor object describing font properties.
 * @return Newly generated bitmap font.
 */
private static BitmapFont generateFont(FontDescriptor fontDescriptor) {

    FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal(fontDescriptor.getFontFilename()));
    FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
    parameter.color = fontDescriptor.getForegroundColor();
    parameter.size = fontDescriptor.getFontSize();
    parameter.borderWidth = fontDescriptor.getBorderWidth();
    parameter.borderColor = fontDescriptor.getBorderColor();
    parameter.borderStraight = fontDescriptor.isStraightBorderUsed();
    BitmapFont font = generator.generateFont(parameter);
    generator.dispose();

    return font;
}
 
Example 25
Project: INFSEN01-2   File: Program.java   Source Code and License 5 votes vote down vote up
@Override
   public void render () {
Gdx.gl.glClearColor(1, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
       
this.batch.begin();
this.batch.draw(this.backgroundImage, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
       this.guiManager.update(this.updateVisitor, Gdx.graphics.getDeltaTime());
       this.guiManager.draw(this.drawVisitor);
this.batch.end();
   }
 
Example 26
Project: school-game   File: MenuState.java   Source Code and License 5 votes vote down vote up
/**
 * Aufräumarbeiten.
 */
@Override
public void dispose() {
    Gdx.app.getApplicationLogger().log("INFO", "Menu dispose...");

    entries.clear();

    batch.dispose();

    Gdx.app.getApplicationLogger().log("INFO", "Menu leave.");
}
 
Example 27
Project: SpaceGame   File: SelectionSystem.java   Source Code and License 5 votes vote down vote up
@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
    if (checkProcessing() && button == Buttons.LEFT) {
        Vector3 vec = camera.unproject(new Vector3(Gdx.input.getX(), Gdx.input.getY(), 0));
        selectionBegin = new Vector2(vec.x, vec.y);
        return true;
    }
    return false;
}
 
Example 28
Project: Cubes_2   File: CameraController.java   Source Code and License 5 votes vote down vote up
private void update(float forward, float backward, float left, float right, boolean jump, boolean descend) {
	int deltaTime = Gdx.graphics.getRawDeltaTime();

	updateIf(deltaTime);

	tryMove();
	boolean onBlock = WorldGravity.onBlock(Cubes.getClient().world, Cubes.getClient().player.position,
			Player.PLAYER_HEIGHT, Player.PLAYER_RADIUS);

	if (flying) {

		innestedIf1(jump, onBlock);

	} else if (jumping) {
		if (!jump) {
			Cubes.getClient().player.motion.y = Math.min(JUMP_RELEASE_VELOCITY, Cubes.getClient().player.motion.y);
			jumping = false;
		}
	} else {
		if (jump && onBlock) {
			Cubes.getClient().player.motion.y = JUMP_START_VELOCITY;
			jumping = true;
		}
	}

	innestedIf2(jump, deltaTime);

}
 
Example 29
Project: KyperBox   File: KyperMapLoader.java   Source Code and License 5 votes vote down vote up
public TiledMap load(String fileName, AtlasTiledMapLoaderParameters parameter) {

		try {
			if (parameter != null) {
				convertObjectToTileSpace = parameter.convertObjectToTileSpace;
				flipY = parameter.flipY;
			} else {
				convertObjectToTileSpace = false;
				flipY = true;
			}

			FileHandle tmxFile = resolve(fileName);
			root = xml.parse(tmxFile);
			ObjectMap<String, TextureAtlas> atlases = new ObjectMap<String, TextureAtlas>();
			FileHandle atlasFile = Gdx.files
					.internal(KyperBoxGame.IMAGE_FOLDER + KyperBoxGame.FILE_SEPARATOR + KyperBoxGame.GAME_ATLAS);
			if (atlasFile == null) {
				throw new GdxRuntimeException("Couldn't load atlas");
			}

			TextureAtlas atlas = new TextureAtlas(atlasFile);
			atlases.put(atlasFile.path(), atlas);

			AtlasResolver.DirectAtlasResolver atlasResolver = new AtlasResolver.DirectAtlasResolver(atlases);
			TiledMap map = loadMap(root, tmxFile, atlasResolver);
			map.setOwnedResources(atlases.values().toArray());
			setTextureFilters(parameter.textureMinFilter, parameter.textureMagFilter);
			return map;
		} catch (IOException e) {
			throw new GdxRuntimeException("Couldn't load tilemap '" + fileName + "'", e);
		}
	}
 
Example 30
Project: guitar-finger-trainer   File: TrainingScreen.java   Source Code and License 5 votes vote down vote up
private void update() {
    if (Gdx.input.justTouched()) {
        this.guiCam.unproject(this.touchPoint.set(Gdx.input.getX(), Gdx.input.getY(), 0));

        if (this.backBounds.contains(this.touchPoint.x, this.touchPoint.y)) {
            this.game.setScreen(new LevelScreen(this.game));
            return;
        }
        if (this.playPauseBounds.contains(this.touchPoint.x, this.touchPoint.y)) {
            SettingsUtil.playEnabled = !SettingsUtil.playEnabled;
            return;
        }
        if (this.restartBounds.contains(this.touchPoint.x, this.touchPoint.y)) {
            this.firstRun = 3;
            this.grid.currentPosition = 0;
            this.grid.forward = true;
            return;
        }
        if (this.backFowardtBounds.contains(this.touchPoint.x, this.touchPoint.y)) {
            SettingsUtil.backForwardEnabled = !SettingsUtil.backForwardEnabled;
            return;
        }
        if (this.soundBounds.contains(this.touchPoint.x, this.touchPoint.y)) {
            SettingsUtil.soundEnabled = !SettingsUtil.soundEnabled;
            return;
        }
        if (this.minusBounds.contains(this.touchPoint.x, this.touchPoint.y)) {
            if (SettingsUtil.bpm > 1) {
                SettingsUtil.bpm--;
                this.bpm = MINUTE_IN_MILLIS / SettingsUtil.bpm;
            }
            return;
        }
        if (this.plusBounds.contains(this.touchPoint.x, this.touchPoint.y)) {
            SettingsUtil.bpm++;
            this.bpm = MINUTE_IN_MILLIS / SettingsUtil.bpm;
        }
    }
}
 
Example 31
Project: summer17-android   File: YouWon.java   Source Code and License 5 votes vote down vote up
@Override
public void render(SpriteBatch sb) {
    sb.begin();
    sb.draw(black, 0, 0, GameTutorial.WIDTH, GameTutorial.HEIGHT);
    sb.end();

    stage.act(Gdx.graphics.getDeltaTime());
    stage.draw();

}
 
Example 32
Project: FlappyChapa   File: GameOverState.java   Source Code and License 5 votes vote down vote up
@Override
public void handleInput() {
    if (Gdx.input.justTouched()) {
        music.stop();
        gsm.set(new MenuState(gsm));
    }
}
 
Example 33
Project: NoRiskNoFun   File: ClientContext.java   Source Code and License 5 votes vote down vote up
public void setState(State state) {

        if (state == null) {
            throw new IllegalArgumentException("state is null");
        }

        Gdx.app.log(getClass().getSimpleName(), this.state.getClass().getSimpleName() + " -> " + state.getClass().getSimpleName());
        data.setCurrentStateName(state.getClass().getSimpleName());
        data.setChangedFlag(true);

        this.state.exit();
        this.state=state;
        this.state.enter();
    }
 
Example 34
Project: INFSEN01-2   File: GDXDrawingAdapter.java   Source Code and License 5 votes vote down vote up
@Override
public void drawRectangle(Point top_left, Float width, Float height, CustomColor color) {
    this.batch.draw(
            this.textureWhite,
            top_left.getX(),
            Gdx.graphics.getHeight() - (top_left.getY() + height),
            width, height);
}
 
Example 35
Project: JGame   File: GameScreen.java   Source Code and License 5 votes vote down vote up
public void updateTitle(boolean onMap) {

		if (onMap) {
			Gdx.graphics.setTitle("JGame " + Integer.toString(Gdx.graphics.getFramesPerSecond()) + " FPS "
					+ eHandler.tileHover(eHandler.handleMouseX(deltaTime), eHandler.handleMouseY(deltaTime)).GetType()
					+ " " + entity.buildPercentage + "%");
		} else {
			Gdx.graphics.setTitle("JGame " + Integer.toString(Gdx.graphics.getFramesPerSecond()) + " FPS "
					+ "No Tile Selected" + " " + entity.buildPercentage + "%");
		}

	}
 
Example 36
Project: MMORPG_Prototype   File: AuthenticationState.java   Source Code and License 5 votes vote down vote up
public AuthenticationState(Client client, StateManager states)
{
	this.client = client;
	this.states = states;
	authenticationDialog = new AuthenticationDialog(this);
	authenticationDialog.show(stage);
	Gdx.input.setInputProcessor(stage);
	try
	{
		Thread.sleep(100);
	} catch (InterruptedException e)
	{
		e.printStackTrace();
	}
}
 
Example 37
Project: PixelDungeonTC   File: PixelScene.java   Source Code and License 5 votes vote down vote up
@Override
public void draw() {
	if (light) {
		Gdx.gl.glBlendFunc( GL20.GL_SRC_ALPHA, GL20.GL_ONE );
		super.draw();
		Gdx.gl.glBlendFunc( GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA );
	} else {
		super.draw();
	}
}
 
Example 38
Project: Parasites-of-HellSpace   File: HealthPack.java   Source Code and License 5 votes vote down vote up
public HealthPack() 
{
	posX = MathUtils.random(350)+ 50;
	posY = Gdx.graphics.getHeight();
	speed = 150f;
	texture = AssetLoader.assetManager.get("medkit.png", Texture.class);
	powerUpSound = AssetLoader.assetManager.get("powerupsnd.wav", Sound.class);
	sprite = new Sprite(texture);
	sprite.setOriginCenter();
	sprite.setScale(0.7f);
	sprite.setPosition(posX, posY);
}
 
Example 39
Project: LibGDX-SplashScreen-Example   File: Core.java   Source Code and License 5 votes vote down vote up
@Override
public void render() {
    Gdx.gl.glClearColor(1, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    batch.begin();
    batch.draw(img, 0, 0);
    batch.end();
}
 
Example 40
Project: Onyx   File: FTFGeneratorCache.java   Source Code and License 5 votes vote down vote up
/**
 * Returns a {@link FreeTypeFontGenerator} that generates a {@link BitmapFont} with a specified path
 *
 * @param fontPath the path of the desired font, relative to {@link Gdx#files#internal()}
 *
 * @return the requested {@link FreeTypeFontGenerator}
 */
public static FreeTypeFontGenerator getFTFGenerator(String fontPath) {
    if (fontPath.equals("default")) throw new IllegalArgumentException("fontPath must not be default, use getDefaultFTFGenerator() instead");
    if (cache.containsKey(fontPath)) return cache.get(fontPath);
    else {
        cache.put(fontPath, new FreeTypeFontGenerator(Gdx.files.internal(fontPath)));
        return cache.get(fontPath);
    }
}