0
\$\begingroup\$

I am using Android studio (libGDX), and I can't figure out why alternative paths doesn't work. I've tried it as it said in the book, but it doesn't do anything, it shows a black window and than the program exterminates. If the .png file would be in the .../android/assets/ folder, it wouldn't work either.

Book: Java Game Development with LibGDX 2nd edition

This is what the book wants me to do it:

public Spaceship(float x, float y, Stage s){

    super(x,y,s);
    loadTexture( "assets/spaceship.png" ); 
    setBoundaryPolygon(8);

    setAcceleration(200);
    setMaxSpeed(100);
    setDeceleration(10);
}

This is the shortest form that works for me:

public Spaceship(float x, float y, Stage stage) {

    super(x, y, stage);

    loadTexture("core/src/com/dusi/game/ch04/assets/spaceship.png");
    setBoundaryPolygon(8);

    setAcceleration(400);
    setMaxSpeed(200);
    setDeceleration(20);
}

This is what my path looks like: enter image description here

\$\endgroup\$
0
\$\begingroup\$

For a Desktop Application
If you are working on a desktop app it has to do with the Run/Debug Configuration:

Example desktop configuration

The important part is to set the "Working directory" to YourGameName\android\assets

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.