-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e860012
commit 087412f
Showing
8 changed files
with
134 additions
and
51 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<tileset version="1.10" tiledversion="1.10.2" name="AlotOfPerson" tilewidth="16" tileheight="16" tilecount="12" columns="4"> | ||
<image source="AlotOfPerson.png" width="64" height="51"/> | ||
</tileset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,95 @@ | ||
//package com.aqwsxlostfly.packandgo.Tools; | ||
// | ||
//import com.aqwsxlostfly.packandgo.Main; | ||
//import com.aqwsxlostfly.packandgo.Screens.GameSc; | ||
//import com.badlogic.gdx.Gdx; | ||
//import com.badlogic.gdx.graphics.Color; | ||
//import com.badlogic.gdx.graphics.g2d.BitmapFont; | ||
//import com.badlogic.gdx.graphics.g2d.GlyphLayout; | ||
//import com.badlogic.gdx.graphics.g2d.SpriteBatch; | ||
//import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; | ||
// | ||
//public class GameHud { | ||
// BitmapFont font; | ||
// public GameHud(){ | ||
// FreeTypeFontGenerator gen = new FreeTypeFontGenerator((Gdx.files.internal(("font.ttf")))); | ||
// FreeTypeFontGenerator.FreeTypeFontParameter p =new FreeTypeFontGenerator.FreeTypeFontParameter(); | ||
// p.size= Main.screenWidth/10; | ||
// p.color = new Color(Color.RED); | ||
// font = gen.generateFont(p); | ||
// } | ||
// public void draw(SpriteBatch batch){ | ||
// GlyphLayout gl = new GlyphLayout(); | ||
// gl.setText(font, GameSc.player.getHealth()+""); | ||
// font.draw(batch,gl,0,Main.screenHeight); | ||
// gl.setText(font,GameSc.player.getScore()+""); | ||
// font.draw(batch,gl,Main.screenWidth- gl.width,Main.screenHeight); | ||
// } | ||
//} | ||
package com.aqwsxlostfly.packandgo.Tools; | ||
|
||
|
||
import static com.aqwsxlostfly.packandgo.AssetManagerSingleton.getAssetManager; | ||
|
||
import com.aqwsxlostfly.packandgo.Heroes.Player; | ||
import com.badlogic.gdx.Gdx; | ||
import com.badlogic.gdx.graphics.Texture; | ||
import com.badlogic.gdx.scenes.scene2d.Stage; | ||
import com.badlogic.gdx.scenes.scene2d.ui.Skin; | ||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton; | ||
import com.badlogic.gdx.scenes.scene2d.InputEvent; | ||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; | ||
import com.badlogic.gdx.utils.viewport.ScreenViewport; | ||
|
||
public class GameHud { | ||
Texture tabouret; | ||
Texture hero; | ||
public Stage stage; // Используется для управления и отображения UI | ||
public Skin skin; // Скин для стилизации элементов UI | ||
public TextButton takeBtn; // Кнопка в UI | ||
public TextButton fightBtn; // Кнопка в UI | ||
public Player player; | ||
|
||
|
||
public GameHud(Player player) { | ||
tabouret = new Texture("tabouret.png"); | ||
hero = new Texture("tile_0456.png"); | ||
// Инициализация скина и сцены | ||
skin = new Skin(Gdx.files.internal("skin/uiskin.json")); | ||
stage = new Stage(new ScreenViewport()); | ||
|
||
// Установка обработчика ввода в текущую сцену | ||
//Gdx.input.setInputProcessor(stage); | ||
|
||
// Создание и настройка кнопки | ||
takeBtn = new TextButton("Take", skin); | ||
fightBtn = new TextButton("GIVE PUSSY", skin); | ||
takeBtn.setSize(250, 150); // Установка размера кнопки | ||
takeBtn.setPosition(Gdx.graphics.getWidth() -450, Gdx.graphics.getHeight() / 2 - 450); // Позиционирование кнопки | ||
fightBtn.setSize(250, 150); // Установка размера кнопки | ||
fightBtn.setPosition(Gdx.graphics.getWidth() -450, Gdx.graphics.getHeight() / 2 - 250); // Позиционирование кнопки | ||
|
||
this.player = player; | ||
|
||
// Добавление кнопки на сцену | ||
stage.addActor(takeBtn); | ||
stage.addActor(fightBtn); | ||
|
||
// Добавление обработчика событий для кнопки | ||
addListeners(); | ||
|
||
} | ||
|
||
public void draw() { | ||
// Отрисовка сцены (и всех элементов UI на ней) | ||
stage.draw(); | ||
} | ||
|
||
public void update(float delta) { | ||
// Обновление сцены | ||
stage.act(delta); | ||
} | ||
|
||
private void addListeners() { | ||
takeBtn.addListener(new ClickListener() { | ||
|
||
@Override | ||
public void clicked(InputEvent event, float x, float y) { | ||
Texture currentTexture = player.textureMapObject.getTextureRegion().getTexture(); | ||
// Обработка нажатия на кнопку | ||
Gdx.app.log("Button Clicked", "Take button was pressed"); | ||
if (currentTexture != tabouret){ | ||
Gdx.app.log("INFO","смена текстуры"); | ||
player.textureMapObject.getTextureRegion().setTexture(tabouret); | ||
|
||
} else{ | ||
//player.textureMapObject.getTextureRegion().setTexture(null); | ||
player.textureMapObject.getTextureRegion().setTexture(hero); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
// Вызовите этот метод в вашем основном цикле приложения для обеспечения обновления UI | ||
public void resize(int width, int height) { | ||
stage.getViewport().update(width, height, true); | ||
} | ||
|
||
// Не забудьте освободить ресурсы | ||
public void dispose() { | ||
stage.dispose(); | ||
skin.dispose(); | ||
} | ||
} |