mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
fixed game hud
This commit is contained in:
@@ -174,14 +174,12 @@ public class GameHUD extends Stage {
|
|||||||
float y=(c.y-miniMap.getY())/miniMap.getHeight();
|
float y=(c.y-miniMap.getY())/miniMap.getHeight();
|
||||||
|
|
||||||
|
|
||||||
float uiX = gamehud.getX();
|
|
||||||
float uiY = gamehud.getY();
|
|
||||||
float uiTop = gamehud.getTop();
|
|
||||||
float uiRight = gamehud.getRight();
|
|
||||||
//gamehud bounds
|
//gamehud bounds
|
||||||
if (c.x>=uiX&&c.x<=uiRight&&c.y>=uiY&&c.y<=uiTop) {
|
for(Actor child:ui.getChildren())
|
||||||
super.touchDown(screenX, screenY, pointer, button);
|
{
|
||||||
return true;
|
if (Controls.actorContainsVector(child,c)) {
|
||||||
|
return super.touchDown(screenX, screenY, pointer, button);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float mMapX = miniMap.getX();
|
float mMapX = miniMap.getX();
|
||||||
@@ -196,16 +194,9 @@ public class GameHUD extends Stage {
|
|||||||
WorldStage.getInstance().GetPlayer().setPosition(x*WorldSave.getCurrentSave().getWorld().getWidthInPixels(),y*WorldSave.getCurrentSave().getWorld().getHeightInPixels());
|
WorldStage.getInstance().GetPlayer().setPosition(x*WorldSave.getCurrentSave().getWorld().getWidthInPixels(),y*WorldSave.getCurrentSave().getWorld().getHeightInPixels());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//display bounds
|
|
||||||
float displayX = ui.getX();
|
|
||||||
float displayY = ui.getY();
|
|
||||||
float displayT = ui.getTop();
|
|
||||||
float displayR = ui.getRight();
|
|
||||||
//auto follow touchpad
|
//auto follow touchpad
|
||||||
if (GuiBase.isAndroid()) {
|
if (GuiBase.isAndroid()) {
|
||||||
if (!(touch.x>=mMapX&&touch.x<=mMapR&&touch.y>=mMapY&&touch.y<=mMapT) // not inside map bounds
|
if ( (Controls.actorContainsVector(ui,touch)) //inside display bounds
|
||||||
&& !(touch.x>=uiX&&touch.x<=uiRight&&touch.y>=uiY&&touch.y<=uiTop) //not inside gamehud bounds
|
|
||||||
&& (touch.x>=displayX&&touch.x<=displayR&&touch.y>=displayY&&touch.y<=displayT) //inside display bounds
|
|
||||||
&& pointer < 1) { //not more than 1 pointer
|
&& pointer < 1) { //not more than 1 pointer
|
||||||
touchpad.setBounds(touch.x-TOUCHPAD_SCALE/2, touch.y-TOUCHPAD_SCALE/2, TOUCHPAD_SCALE, TOUCHPAD_SCALE);
|
touchpad.setBounds(touch.x-TOUCHPAD_SCALE/2, touch.y-TOUCHPAD_SCALE/2, TOUCHPAD_SCALE, TOUCHPAD_SCALE);
|
||||||
touchpad.setVisible(true);
|
touchpad.setVisible(true);
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import com.badlogic.gdx.graphics.Texture;
|
|||||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||||
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
|
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
|
||||||
|
import com.badlogic.gdx.math.Rectangle;
|
||||||
|
import com.badlogic.gdx.math.Vector2;
|
||||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.*;
|
import com.badlogic.gdx.scenes.scene2d.ui.*;
|
||||||
@@ -26,6 +28,14 @@ public class Controls {
|
|||||||
|
|
||||||
return new TextButton(text, GetSkin());
|
return new TextButton(text, GetSkin());
|
||||||
}
|
}
|
||||||
|
static public Rectangle getBoundingRect(Actor actor) {
|
||||||
|
|
||||||
|
return new Rectangle(actor.getX(),actor.getY(),actor.getWidth(),actor.getHeight());
|
||||||
|
}
|
||||||
|
static public boolean actorContainsVector (Actor actor, Vector2 point) {
|
||||||
|
|
||||||
|
return getBoundingRect(actor).contains(point);
|
||||||
|
}
|
||||||
|
|
||||||
static public SelectBox newComboBox(String[] text, String item, Function<Object, Void> func) {
|
static public SelectBox newComboBox(String[] text, String item, Function<Object, Void> func) {
|
||||||
SelectBox ret = new SelectBox<String>(GetSkin());
|
SelectBox ret = new SelectBox<String>(GetSkin());
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ public class Current {
|
|||||||
{
|
{
|
||||||
return debug;
|
return debug;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setDebug(boolean b) {
|
public static void setDebug(boolean b) {
|
||||||
debug=b;
|
debug=b;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user