Error when using JPlay framework for games!

0
Hello, I'm trying to program in java with the JPlay framework, and I'm finding an error that was non-existent on another pc I had. The error step is in this video lesson: link

game class code:

package jogo;

import jplay.GameImage;
import jplay.URL;
import jplay.Window;

public class Main {
  public static void main(String[] args) {
     Window janela = new Window(800,600);
     GameImage plano = new GameImage(URL.sprite("menu.png"));

     while(true){
         plano.draw();
         janela.update();    
     }
 } }

The error is the background image that does not render. I am using version 1.8 of java. I hope friends can help me solve this "gray screen" problem.

    
asked by anonymous 16.05.2018 / 02:53

1 answer

0

I went through the same situation and the solution is very simple ...

Instead of vs do:

GameImage plano = new GameImage(URL.sprite("menu.png")); 

vs should pass the direct path of the image, which in your case would be src / resources / sprites / menu.png .. Getting like this:

GameImage plano = new GameImage("src/recursos/sprites/menu.png");

You need to do this also for the tiles files and scn scenario files, that is, do not use the URL class and use the direct path of the file you want to use vs do not give error.

Upload scenario file:

cena.loadFromFile("src/recursos/cenarios/Cenario1.scn")

To load the tiles files just put the full path of it in the scenario file.

If you do it right, it will not go wrong. I hope it works out! : D

    
10.08.2018 / 10:48