Refactor how skin images are loaded

Further enhance match layout
This commit is contained in:
drdev
2014-03-03 00:27:53 +00:00
parent 4dec8f1329
commit 06192e71b8
20 changed files with 292 additions and 173 deletions

1
.gitattributes vendored
View File

@@ -16005,6 +16005,7 @@ forge-m-base/src/forge/assets/FSkin.java -text
forge-m-base/src/forge/assets/FSkinColor.java -text
forge-m-base/src/forge/assets/FSkinFont.java -text
forge-m-base/src/forge/assets/FSkinImage.java -text
forge-m-base/src/forge/assets/FSkinTexture.java -text
forge-m-base/src/forge/player/LobbyPlayerHuman.java -text
forge-m-base/src/forge/player/PlayerControllerHuman.java -text
forge-m-base/src/forge/screens/FScreen.java -text

View File

@@ -8,6 +8,7 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
@@ -413,6 +414,9 @@ public class Forge implements ApplicationListener {
public void drawImage(FImage image, float x, float y, float w, float h) {
image.draw(this, x, y, w, h);
}
public void drawImage(Texture image, float x, float y, float w, float h) {
batch.draw(image, adjustX(x), adjustY(y, h), w, h);
}
public void drawImage(TextureRegion image, float x, float y, float w, float h) {
batch.draw(image, adjustX(x), adjustY(y, h), w, h);
}

View File

@@ -3,7 +3,7 @@ package forge.assets;
import forge.Forge.Graphics;
public interface FImage {
float getSourceWidth();
float getSourceHeight();
float getWidth();
float getHeight();
void draw(Graphics g, float x, float y, float w, float h);
}

View File

@@ -23,7 +23,6 @@ public class FSkin {
FILE_AVATAR_SPRITE = "sprite_avatars.png",
DEFAULT_DIR = FILE_SKINS_DIR + "default/";
private static final Map<FSkinImage, TextureRegion> images = new HashMap<FSkinImage, TextureRegion>();
private static final Map<Integer, TextureRegion> avatars = new HashMap<Integer, TextureRegion>();
private static ArrayList<String> allSkins;
@@ -65,14 +64,12 @@ public class FSkin {
}
}
images.clear();
// Non-default (preferred) skin name and dir.
preferredName = skinName.toLowerCase().replace(' ', '_');
preferredDir = FILE_SKINS_DIR + preferredName + "/";
if (splashScreen != null) {
final FileHandle f = Gdx.files.internal(preferredDir + SourceFile.SPLASH.getFilename());
final FileHandle f = Gdx.files.internal(preferredDir + "bg_splash.png");
if (!f.exists()) {
if (!skinName.equals("default")) {
FSkin.loadLight("default", splashScreen);
@@ -161,12 +158,12 @@ public class FSkin {
c.setColor(new Color(preferredIcons.getPixel(c.getX(), c.getY())));
}
//add images
//load images
for (FSkinImage image : FSkinImage.values()) {
TextureRegion textureRegion = loadTextureRegion(image, textures, preferredIcons);
if (textureRegion != null) {
images.put(image, textureRegion);
}
image.load(preferredDir, DEFAULT_DIR, textures, preferredIcons);
}
for (FSkinTexture image : FSkinTexture.values()) {
image.load(preferredDir, DEFAULT_DIR);
}
//assemble avatar textures
@@ -269,91 +266,6 @@ public class FSkin {
addEncodingSymbol("T", GameplayImages.IMG_TAP);*/
}
private static TextureRegion loadTextureRegion(FSkinImage image, Map<String, Texture> textures, Pixmap preferredIcons) {
SourceFile sourceFile = image.getSourceFile();
String filename = sourceFile.getFilename();
String preferredFile = preferredDir + filename;
Texture texture = textures.get(preferredFile);
if (texture == null) {
FileHandle file = Gdx.files.internal(preferredFile);
if (file.exists()) {
try {
texture = new Texture(file);
}
catch (final Exception e) {
System.err.println("Failed to load skin file: " + preferredFile);
e.printStackTrace();
}
}
}
if (texture != null) {
int fullWidth = texture.getWidth();
int fullHeight = texture.getHeight();
int x0 = image.getX();
int y0 = image.getY();
int w0 = image.getWidth(fullWidth);
int h0 = image.getHeight(fullHeight);
if (sourceFile != SourceFile.ICONS) { //just return region for preferred file if not icons file
return new TextureRegion(texture, x0, y0, w0, h0);
}
else {
// Test if requested sub-image in inside bounds of preferred sprite.
// (Height and width of preferred sprite were set in loadFontAndImages.)
if (x0 + w0 <= fullWidth && y0 + h0 <= fullHeight) {
// Test if various points of requested sub-image are transparent.
// If any return true, image exists.
int x = 0, y = 0;
Color c;
// Center
x = (x0 + w0 / 2);
y = (y0 + h0 / 2);
c = new Color(preferredIcons.getPixel(x, y));
if (c.a != 0) { return new TextureRegion(texture, x0, y0, w0, h0); }
x += 2;
y += 2;
c = new Color(preferredIcons.getPixel(x, y));
if (c.a != 0) { return new TextureRegion(texture, x0, y0, w0, h0); }
x -= 4;
c = new Color(preferredIcons.getPixel(x, y));
if (c.a != 0) { return new TextureRegion(texture, x0, y0, w0, h0); }
y -= 4;
c = new Color(preferredIcons.getPixel(x, y));
if (c.a != 0) { return new TextureRegion(texture, x0, y0, w0, h0); }
x += 4;
c = new Color(preferredIcons.getPixel(x, y));
if (c.a != 0) { return new TextureRegion(texture, x0, y0, w0, h0); }
}
}
}
//use default file if can't use preferred file
String defaultFile = DEFAULT_DIR + filename;
texture = textures.get(defaultFile);
if (texture == null) {
FileHandle file = Gdx.files.internal(defaultFile);
if (file.exists()) {
try {
texture = new Texture(file);
}
catch (final Exception e) {
System.err.println("Failed to load skin file: " + defaultFile);
e.printStackTrace();
}
}
}
if (texture != null) {
return new TextureRegion(texture, image.getX(), image.getY(),
image.getWidth(texture.getWidth()), image.getHeight(texture.getHeight()));
}
return null;
}
/**
* Gets the name.
*
@@ -406,10 +318,6 @@ public class FSkin {
return allSkins;
}
public static Map<FSkinImage, TextureRegion> getImages() {
return images;
}
public static Map<Integer, TextureRegion> getAvatars() {
return avatars;
}

View File

@@ -1,15 +1,20 @@
package forge.assets;
import java.util.Map;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import forge.Forge.Graphics;
/** Properties of various components that make up the skin.
* This interface allows all enums to be under the same roof.
* It also enforces a getter for coordinate locations in sprites. */
public enum FSkinImage implements FImage {
//Backgrounds
BG_TEXTURE (0, 0, 0, 0, SourceFile.TEXTURE),
BG_MATCH (0, 0, 0, 0, SourceFile.MATCH),
//Zones
HAND (280, 40, 40, 40, SourceFile.ICONS),
LIBRARY (280, 0, 40, 40, SourceFile.ICONS),
@@ -227,10 +232,7 @@ public enum FSkinImage implements FImage {
public enum SourceFile {
ICONS("sprite_icons.png"),
FOILS("sprite_foils.png"),
OLD_FOILS("sprite_old_foils.png"),
SPLASH("bg_splash.png"),
MATCH("bg_match.jpg"),
TEXTURE("bg_texture.jpg");
OLD_FOILS("sprite_old_foils.png");
private final String filename;
@@ -245,6 +247,7 @@ public enum FSkinImage implements FImage {
private final int x, y, w, h;
private final SourceFile sourceFile;
private TextureRegion textureRegion;
FSkinImage(int x0, int y0, int w0, int h0, SourceFile sourceFile0) {
x = x0;
@@ -254,44 +257,111 @@ public enum FSkinImage implements FImage {
sourceFile = sourceFile0;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public int getWidth(int fullWidth) {
if (w > 0) {
return w;
public void load(String preferredDir, String defaultDir, Map<String, Texture> textures, Pixmap preferredIcons) {
String filename = sourceFile.getFilename();
String preferredFile = preferredDir + filename;
Texture texture = textures.get(preferredFile);
if (texture == null) {
FileHandle file = Gdx.files.internal(preferredFile);
if (file.exists()) {
try {
texture = new Texture(file);
}
catch (final Exception e) {
System.err.println("Failed to load skin file: " + preferredFile);
e.printStackTrace();
}
}
}
return fullWidth + w;
}
if (texture != null) {
if (sourceFile != SourceFile.ICONS) { //just return region for preferred file if not icons file
textureRegion = new TextureRegion(texture, x, y, w, h);
return;
}
public int getHeight(int fullHeight) {
if (h > 0) {
return h;
int fullWidth = texture.getWidth();
int fullHeight = texture.getHeight();
// Test if requested sub-image in inside bounds of preferred sprite.
// (Height and width of preferred sprite were set in loadFontAndImages.)
if (x + w <= fullWidth && y + h <= fullHeight) {
// Test if various points of requested sub-image are transparent.
// If any return true, image exists.
int x0 = 0, y0 = 0;
Color c;
// Center
x0 = (x + w / 2);
y0 = (y + h / 2);
c = new Color(preferredIcons.getPixel(x0, y0));
if (c.a != 0) {
textureRegion = new TextureRegion(texture, x, y, w, h);
return;
}
x0 += 2;
y0 += 2;
c = new Color(preferredIcons.getPixel(x0, y0));
if (c.a != 0) {
textureRegion = new TextureRegion(texture, x, y, w, h);
return;
}
x0 -= 4;
c = new Color(preferredIcons.getPixel(x0, y0));
if (c.a != 0) {
textureRegion = new TextureRegion(texture, x, y, w, h);
return;
}
y0 -= 4;
c = new Color(preferredIcons.getPixel(x0, y0));
if (c.a != 0) {
textureRegion = new TextureRegion(texture, x, y, w, h);
return;
}
x0 += 4;
c = new Color(preferredIcons.getPixel(x0, y0));
if (c.a != 0) {
textureRegion = new TextureRegion(texture, x, y, w, h);
return;
}
}
}
return fullHeight + h;
}
public SourceFile getSourceFile() {
return sourceFile;
//use default file if can't use preferred file
String defaultFile = defaultDir + filename;
texture = textures.get(defaultFile);
if (texture == null) {
FileHandle file = Gdx.files.internal(defaultFile);
if (file.exists()) {
try {
texture = new Texture(file);
}
catch (final Exception e) {
System.err.println("Failed to load skin file: " + defaultFile);
e.printStackTrace();
}
}
}
if (texture != null) {
textureRegion = new TextureRegion(texture, x, y, w, h);
}
}
@Override
public float getSourceWidth() {
public float getWidth() {
return w;
}
@Override
public float getSourceHeight() {
public float getHeight() {
return h;
}
@Override
public void draw(Graphics g, float x, float y, float w, float h) {
g.drawImage(FSkin.getImages().get(this), x, y, w, h);
g.drawImage(this.textureRegion, x, y, w, h);
}
}

View File

@@ -0,0 +1,61 @@
package forge.assets;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Texture;
import forge.Forge.Graphics;
public enum FSkinTexture implements FImage {
BG_TEXTURE("bg_texture.jpg"),
BG_MATCH("bg_match.jpg");
private final String filename;
private Texture texture;
FSkinTexture(String filename0) {
filename = filename0;
}
public void load(String preferredDir, String defaultDir) {
String preferredFile = preferredDir + filename;
FileHandle file = Gdx.files.internal(preferredFile);
if (file.exists()) {
try {
texture = new Texture(file);
}
catch (final Exception e) {
System.err.println("Failed to load skin file: " + preferredFile);
e.printStackTrace();
}
}
if (texture == null) {
//use default file if can't use preferred file
String defaultFile = defaultDir + filename;
file = Gdx.files.internal(defaultFile);
if (file.exists()) {
try {
texture = new Texture(file);
}
catch (final Exception e) {
System.err.println("Failed to load skin file: " + defaultFile);
e.printStackTrace();
}
}
}
}
@Override
public float getWidth() {
return texture.getWidth();
}
@Override
public float getHeight() {
return texture.getHeight();
}
@Override
public void draw(Graphics g, float x, float y, float w, float h) {
g.drawImage(texture, x, y, w, h);
}
}

View File

@@ -7,18 +7,22 @@ import forge.Forge.Graphics;
import forge.assets.FSkinColor;
import forge.assets.FSkinImage;
import forge.assets.FSkinColor.Colors;
import forge.assets.FSkinTexture;
import forge.toolbox.FContainer;
import forge.toolbox.FLabel;
import forge.utils.Utils;
public abstract class FScreen extends FContainer {
public static final float BTN_WIDTH = Utils.AVG_FINGER_WIDTH;
public static final float BTN_HEIGHT = Utils.AVG_FINGER_HEIGHT;
private static final FSkinColor clrTheme = FSkinColor.get(Colors.CLR_THEME);
private static final FSkinColor clr = clrTheme.stepColor(0);
private static final FSkinColor a100 = clr.alphaColor(100f / 255f);
private static final FSkinColor d40 = clr.stepColor(-40);
private static final FSkinColor d80 = clr.stepColor(-80);
protected final FLabel btnBack, lblHeader, btnMenu;
private final FLabel btnBack, lblHeader, btnMenu;
protected FScreen(boolean showBackButton, String headerCaption, boolean showMenuButton) {
if (showBackButton) {
@@ -75,16 +79,15 @@ public abstract class FScreen extends FContainer {
float headerX = 0;
float insets = 0;
float headerWidth = width;
float buttonWidth = Utils.AVG_FINGER_WIDTH;
float headerHeight = Utils.AVG_FINGER_HEIGHT;
float headerHeight = BTN_HEIGHT;
if (btnBack != null) {
btnBack.setBounds(insets, insets, buttonWidth, headerHeight);
btnBack.setBounds(insets, insets, BTN_WIDTH, BTN_HEIGHT);
headerX = btnBack.getWidth();
headerWidth -= headerX;
}
if (btnMenu != null) {
btnMenu.setBounds(width - buttonWidth - insets, insets, buttonWidth, headerHeight);
btnMenu.setBounds(width - BTN_WIDTH - insets, insets, BTN_WIDTH, BTN_HEIGHT);
headerWidth -= btnMenu.getWidth();
}
if (lblHeader != null) {
@@ -103,7 +106,7 @@ public abstract class FScreen extends FContainer {
protected void drawBackground(Graphics g) {
float w = getWidth();
float h = getHeight();
g.drawImage(FSkinImage.BG_TEXTURE, 0, 0, w, h);
g.drawImage(FSkinTexture.BG_TEXTURE, 0, 0, w, h);
g.fillRect(clrTheme, 0, 0, w, h);
if (lblHeader != null) { //draw custom background behind header label

View File

@@ -24,8 +24,8 @@ public abstract class LaunchScreen extends FScreen {
@Override
protected final void doLayout(float startY, float width, float height) {
float imageWidth = FSkinImage.BTN_START_UP.getSourceWidth();
float imageHeight = FSkinImage.BTN_START_UP.getSourceHeight();
float imageWidth = FSkinImage.BTN_START_UP.getWidth();
float imageHeight = FSkinImage.BTN_START_UP.getHeight();
float padding = imageHeight * 0.1f;
btnStart.setBounds((width - imageWidth) / 2, height - imageHeight - padding, imageWidth, imageHeight);

View File

@@ -26,12 +26,14 @@ public class ConstructedScreen extends LaunchScreen {
//TODO: Allow picking decks
Deck humanDeck = Utils.generateRandomDeck(2);
LobbyPlayerHuman humanLobbyPlayer = new LobbyPlayerHuman("Human");
humanLobbyPlayer.setAvatarIndex(0);
RegisteredPlayer humanRegisteredPlayer = new RegisteredPlayer(humanDeck);
humanRegisteredPlayer.setPlayer(humanLobbyPlayer);
launchParams.players.add(humanRegisteredPlayer);
Deck aiDeck = Utils.generateRandomDeck(2);
LobbyPlayerAi aiLobbyPlayer = new LobbyPlayerAi("AI Player");
aiLobbyPlayer.setAvatarIndex(1);
RegisteredPlayer aiRegisteredPlayer = new RegisteredPlayer(aiDeck);
aiRegisteredPlayer.setPlayer(aiLobbyPlayer);
launchParams.players.add(aiRegisteredPlayer);

View File

@@ -1,7 +1,6 @@
package forge.screens.match;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import forge.screens.FScreen;
@@ -9,9 +8,7 @@ import forge.screens.match.views.VLog;
import forge.screens.match.views.VPlayerPanel;
import forge.screens.match.views.VPrompt;
import forge.screens.match.views.VStack;
import forge.utils.Utils;
import forge.game.Match;
import forge.game.player.Player;
import forge.game.player.RegisteredPlayer;
public class MatchScreen extends FScreen {
@@ -46,16 +43,12 @@ public class MatchScreen extends FScreen {
@Override
protected void doLayout(float startY, float width, float height) {
float logHeight = btnMenu.getHeight();
float stackWidth = Utils.AVG_FINGER_WIDTH;
float stackHeight = stackWidth * Utils.CARD_ASPECT_RATIO;
float promptHeight = Utils.AVG_FINGER_HEIGHT;
float playerPanelHeight = (height - startY - promptHeight - logHeight) / 2f;
float playerPanelHeight = (height - startY - VPrompt.HEIGHT - VLog.HEIGHT) / 2f;
log.setBounds(0, startY, width - btnMenu.getWidth(), logHeight);
topPlayerPanel.setBounds(0, startY + logHeight, width, playerPanelHeight);
stack.setBounds(0, startY + logHeight + playerPanelHeight - stackHeight / 2, stackWidth, stackHeight);
bottomPlayerPanel.setBounds(0, height - promptHeight - playerPanelHeight, width, playerPanelHeight);
prompt.setBounds(0, height - promptHeight, width, promptHeight);
log.setBounds(0, startY, width - FScreen.BTN_WIDTH, VLog.HEIGHT);
topPlayerPanel.setBounds(0, startY + VLog.HEIGHT, width, playerPanelHeight);
stack.setBounds(0, startY + VLog.HEIGHT + playerPanelHeight - VStack.HEIGHT / 2, VStack.WIDTH, VStack.HEIGHT);
bottomPlayerPanel.setBounds(0, height - VPrompt.HEIGHT - playerPanelHeight, width, playerPanelHeight);
prompt.setBounds(0, height - VPrompt.HEIGHT, width, VPrompt.HEIGHT);
}
}

View File

@@ -1,5 +1,27 @@
package forge.screens.match.views;
public class VAvatar {
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import forge.Forge.Graphics;
import forge.assets.FSkin;
import forge.toolbox.FDisplayObject;
import forge.utils.Utils;
public class VAvatar extends FDisplayObject {
public static final float WIDTH = Utils.AVG_FINGER_WIDTH;
public static final float HEIGHT = Utils.AVG_FINGER_HEIGHT;
private final TextureRegion image;
public VAvatar(int avatarIndex) {
image = FSkin.getAvatars().get(avatarIndex);
setSize(WIDTH, HEIGHT);
}
@Override
public void draw(Graphics g) {
float w = getWidth();
float h = getHeight();
g.drawImage(image, 0, 0, w, h);
}
}

View File

@@ -1,13 +1,33 @@
package forge.screens.match.views;
import forge.Forge.Graphics;
import forge.assets.FSkinTexture;
import forge.toolbox.FContainer;
public class VField extends FContainer {
private boolean flipped;
public VField() {
}
public boolean isFlipped() {
return flipped;
}
public void setFlipped(boolean flipped0) {
flipped = flipped0;
}
@Override
protected void doLayout(float width, float height) {
// TODO Auto-generated method stub
}
@Override
protected void drawBackground(Graphics g) {
float w = getWidth();
float h = getHeight();
g.drawImage(FSkinTexture.BG_MATCH, 0, 0, w, h);
}
}

View File

@@ -3,9 +3,11 @@ package forge.screens.match.views;
import com.badlogic.gdx.graphics.Color;
import forge.Forge.Graphics;
import forge.screens.FScreen;
import forge.toolbox.FContainer;
public class VLog extends FContainer {
public static final float HEIGHT = FScreen.BTN_HEIGHT; //TODO: Consider changing this
@Override
protected void doLayout(float width, float height) {

View File

@@ -1,5 +1,8 @@
package forge.screens.match.views;
import com.badlogic.gdx.graphics.Color;
import forge.Forge.Graphics;
import forge.toolbox.FContainer;
public class VPhases extends FContainer {
@@ -10,4 +13,10 @@ public class VPhases extends FContainer {
}
@Override
protected void drawBackground(Graphics g) {
float w = getWidth();
float h = getHeight();
g.fillRect(Color.CYAN, 0, 0, w, h);
}
}

View File

@@ -1,10 +1,8 @@
package forge.screens.match.views;
import com.badlogic.gdx.graphics.Color;
import forge.Forge.Graphics;
import forge.game.player.RegisteredPlayer;
import forge.toolbox.FContainer;
import forge.toolbox.FDisplayObject;
public class VPlayerPanel extends FContainer {
private final RegisteredPlayer player;
@@ -12,32 +10,33 @@ public class VPlayerPanel extends FContainer {
private final VField field;
private final VAvatar avatar;
private boolean flipped;
public VPlayerPanel(RegisteredPlayer player0) {
player = player0;
phases = new VPhases();
field = new VField();
avatar = new VAvatar();
phases = add(new VPhases());
field = add(new VField());
avatar = add(new VAvatar(player.getPlayer().getAvatarIndex()));
}
public boolean isFlipped() {
return flipped;
return field.isFlipped();
}
public void setFlipped(boolean flipped0) {
flipped = flipped0;
field.setFlipped(flipped0);
}
@Override
protected void doLayout(float width, float height) {
// TODO Auto-generated method stub
}
//layout for bottom panel by default
float phasesTop = VStack.HEIGHT / 2;
float phasesWidth = VStack.WIDTH;
phases.setBounds(0, phasesTop, phasesWidth, height - VAvatar.HEIGHT - phasesTop);
field.setBounds(phasesWidth, 0, width - phasesWidth, height - VAvatar.HEIGHT);
avatar.setPosition(0, height - VAvatar.HEIGHT);
@Override
protected void drawBackground(Graphics g) {
float w = getWidth();
float h = getHeight();
g.fillRect(flipped ? Color.LIGHT_GRAY : Color.GRAY, 0, 0, w, h);
if (isFlipped()) { //flip all positions across x-axis if needed
for (FDisplayObject child : getChildren()) {
child.setTop(height - child.getBottom());
}
}
}
}

View File

@@ -4,8 +4,10 @@ import com.badlogic.gdx.graphics.Color;
import forge.Forge.Graphics;
import forge.toolbox.FContainer;
import forge.utils.Utils;
public class VPrompt extends FContainer {
public static final float HEIGHT = Utils.AVG_FINGER_HEIGHT;
@Override
protected void doLayout(float width, float height) {

View File

@@ -4,8 +4,15 @@ import com.badlogic.gdx.graphics.Color;
import forge.Forge.Graphics;
import forge.toolbox.FContainer;
import forge.utils.Utils;
public class VStack extends FContainer {
public static final float WIDTH = Utils.AVG_FINGER_WIDTH;
public static final float HEIGHT = WIDTH * Utils.CARD_ASPECT_RATIO;
public VStack() {
setSize(WIDTH, HEIGHT);
}
@Override
protected void doLayout(float width, float height) {

View File

@@ -12,6 +12,10 @@ public abstract class FContainer extends FDisplayObject {
return child;
}
public Iterable<FDisplayObject> getChildren() {
return children;
}
protected void drawBackground(Graphics g) {
}

View File

@@ -24,21 +24,33 @@ public abstract class FDisplayObject {
public float getLeft() {
return bounds.x;
}
public void setLeft(float x) {
bounds.x = x;
}
public float getRight() {
return bounds.x + bounds.width;
}
public float getTop() {
return bounds.y;
}
public void setTop(float y) {
bounds.y = y;
}
public float getBottom() {
return bounds.y + bounds.height;
}
public float getWidth() {
return bounds.width;
}
public void setWidth(float width) {
bounds.width = width;
}
public float getHeight() {
return bounds.height;
}
public void setHeight(float height) {
bounds.height = height;
}
public boolean contains(float x, float y) {
return visible && bounds.contains(x, y);
}

View File

@@ -186,8 +186,8 @@ public class FLabel extends FDisplayObject {
}
if (icon != null) {
float iconWidth = icon.getSourceWidth();
float iconHeight = icon.getSourceHeight();
float iconWidth = icon.getWidth();
float iconHeight = icon.getHeight();
float aspectRatio = iconWidth / iconHeight;
if (iconInBackground || iconScaleAuto) {