TransWikia.com

Alternative path not working

Game Development Asked by Düsüngülü Tibor on November 12, 2021

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

One Answer

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 YourGameNameandroidassets

Answered by Luis Fernando Frontanilla on November 12, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP