Panel użytkownika
Nazwa użytkownika:
Hasło:
Nie masz jeszcze konta?

[Java libGDX] Android Studio podkreśla na czerwono plik

Ostatnio zmodyfikowano 2026-01-10 13:03
Autor Wiadomość
tBane
Temat założony przez niniejszego użytkownika
[Java libGDX] Android Studio podkreśla na czerwono plik
» 2026-01-09 14:09:59
Witam. Refaktoryzuję kod. Android Studio podkreśla mi plik GemColor.java na czerwono. Nie wiem dlaczego. Co jest nie tak z poniższym kodem ?




package com.tbane.mysticgems.Game;

public class GemColor {
    public float r, g, b;

    public GemColor(float r, float g, float b) {

        this.r = r;
        this.g = g;
        this.b = b;
    }

    public static GemColor rgb(float h, float s, float v) {
        h = (h % 360.0f + 360.0f) % 360f;

        float c = v * s;
        float x = c * (1f - Math.abs((h / 60.0f) % 2.0f - 1.0f));
        float m = v - c;

        float r, g, b;
        if (h < 60.0f) {
            r = c;
            g = x;
            b = 0;
        } else if (h < 120.0f) {
            r = x;
            g = c;
            b = 0;
        } else if (h < 180.0f) {
            r = 0;
            g = c;
            b = x;
        } else if (h < 240.0f) {
            r = 0;
            g = x;
            b = c;
        } else if (h < 300.0f) {
            r = x;
            g = 0;
            b = c;
        } else {
            r = c;
            g = 0;
            b = x;
        }

        return new GemColor(r + m, g + m, b + m);
    }
}


Tak samo podkreśla mi plik AssetsManager.java. Ale projekt się uruchamia i jest git. To moja wina czy to IDE źle kod przetwarza?

package com.tbane.mysticgems;

import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.Texture;

public class AssetsManager {
    public static AssetManager manager;

    static {

        manager = new AssetManager();

        loadTexture("tex/topBoard.png");
        loadTexture("tex/bottomBoard.png");
        loadTexture("tex/mainBoard.png");
        loadTexture("tex/panel.png");
        loadTexture("tex/smallPanel.png");

        loadTexture("tex/titleFrame.png");

        loadTexture("tex/mainMenuLeftSign.png");
        loadTexture("tex/mainMenuRightSign.png");

        loadTexture("tex/menuButtonNormal.png");
        loadTexture("tex/menuButtonHover.png");
        loadTexture("tex/menuButtonPressed.png");

        loadTexture("tex/panelButtonNormal.png");
        loadTexture("tex/panelButtonHover.png");
        loadTexture("tex/panelButtonPressed.png");

        loadTexture("tex/backButtonNormal.png");
        loadTexture("tex/backButtonHover.png");
        loadTexture("tex/backButtonPressed.png");

        loadTexture("tex/awardCup.png");

        loadTexture("tex/underwater.png");

        loadTexture("tex/bubble.png");
        loadTexture("tex/red.png");
        loadTexture("tex/green.png");
        loadTexture("tex/blue.png");
        loadTexture("tex/cyan.png");
        loadTexture("tex/magenta.png");
        loadTexture("tex/yellow.png");

        manager.finishLoading();
    }

    public static void loadTexture(String path) {
        if (!manager.isLoaded(path, Texture.class)) {
            manager.load(path, Texture.class);
        }
    }

    public static Texture getTexture(String path) {
        if (manager.isLoaded(path, Texture.class)) {
            return manager.get(path, Texture.class);
        }
        return null;
    }

    public static Texture getTexture(int colorIndex) {
        Texture texture;

        switch (colorIndex) {
            case 0: texture = getTexture("tex/red.png"); break;
            case 1: texture = getTexture("tex/green.png"); break;
            case 2: texture = getTexture("tex/blue.png"); break;
            case 3: texture = getTexture("tex/yellow.png"); break;
            case 4: texture = getTexture("tex/magenta.png"); break;
            case 5: texture = getTexture("tex/cyan.png"); break;
            default: texture = null; break;
        }

        return texture;
    }

}
P-183783
tBane
Temat założony przez niniejszego użytkownika
» 2026-01-10 13:03:03
Android Studio już nie pokazuje błędów - nic nie zmieniłem :P
P-183787
« 1 »
  Strona 1 z 1