last day (14 days later) » 

1:09 PM
1
A: Libgdx export standalone desktop game without having to put all assets in the same folder?

Abhishek AryanIf you want to export standalone jar from desktop module. Libgdx uses gradle for project building so Hopefully you're using gradle and IntellijIDEA or Android Studio as IDE. Open Terminal View -> Tool Windows-> Terminal or Alt+ F12 run command gradlew desktop:dist It will put all your as...

 
OE1
I am at the main directory of the project and I had gradlew: command not found. Should I be installing something for it? (using mac btw)
nvm just read this stackoverflow.com/questions/27094492/…, going to try now
 
I am using above command on window. Have you tried your link.
 
OE1
FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':core:compileJava'. > Compilation failed; see the compiler error output for details.
 
what is the compiler error output ?
 
OE1
Have no idea what this means: Received result Failure[value=org.gradle.initialization.ReportedException: org.gradle.internal.exceptions.LocationAwareException: Execution failed for task ':core:compileJava'.] from daemon DaemonInfo{pid=32186, address=[dff5876f-b29e-490d-ac21-f74cc968b62a port:56263, addresses:[/0:0:0:0:0:0:0:1, /127.0.0.1]], idle=true, context=DefaultDaemonContext[uid=e716ba8f-26f8-4805-b9d7-594‌​33b545881,javaHome‌​=/‌​Library/Java/JavaVir‌​tualMachines/jdk1.8.‌​0_05.jdk/Contents/Ho‌​me,daemonRe‌​gistryDir‌​=/Users/MIKE/.gradle‌​/daemon,...(too long to paste here)]} (build should be done).
Looked with --debug option and found out this, probably its not able to find one of the dependencies error: package com.apple.eawt.AppEvent does not exist
I was just able to get around the error, I just got rid of the import in my code and handled it in a different way. Now I get build successful but I cant find any executable/jar anywhere
 
1:09 PM
dektop module -> build -> libs -> desktop-1.0.jar in my window. check your's in mac
 
OE1
I found it but it still crashes when I dont have assets in the same folder
 
what is crash report ?
run with cmd
 
OE1
ok, ill do it now
 
java -jar desktop.jar
 
OE1
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load dependencies of asset: SelectEffect.png
so it fails to load assets since it cant find them in the same directory, but again it is able to load the background image even its not in the same directory
 
1:12 PM
where you kept SelectEffect.png
 
OE1
in android's assets folder
its working when I run from eclipse etc
 
Is you created this jar using gradle ?
which IDE you're using ?
 
OE1
I am using eclipse
libgdx
 
Why don't you try Android Studio or IntellijIDEA
deployment of libgdx module is quite easy in these IDE
 
OE1
Im not really familiar with them, thats why I expect to stumble many questions if I try to change the environment now
Do you think it would be rather smooth if I just download one of them and try to deploy on them using a tutorial or something?
 
1:18 PM
ya
ya try IntellijIDEA
Even Google stopped supporting Eclipse for Android development.
 
OE1
Wow really :D
Currently I am going to use this on desktop though (try to deploy to ios/android later maybe), so if you are suggesting intellijIDEA just because of the android part, I might just as well stick with the files for desktop
 
no it's not for android
 
OE1
downloading IntellijIDEA for mac now
 
It's for libgdx. Libgdx uses gradle for building his module . Gradle work fine in IntellijIDEA
 
OE1
ah okay
 
1:26 PM
More than 2 years back I was using Eclipse but now I prefer IntellijIDEA
 
OE1
what will I have to do after the download completes? is it just as simple as exporting a gradle project in eclipse?
 
import your project with gradle
what is the status ? Have you imported your project ?
 
OE1
i just opened the idea
should i create a launching script? i dont know if its necessary to be able to use it?
use idea I mean
 
1:43 PM
Run your desktop module
 
OE1
im importing the gradle project now
 
k
import it then run your project through IDE
 
OE1
its saying java home not defined
I already passed the launching script part, could this be it?
(I already clicked next to see if it would complain and didnt so I moved on)
found it on stackoverflow, im defining it now
 
Open project Structure -> Project -> Project SDK -> Add your java here
 
OE1
still trying to find where my jdk is
ran this: ls -l which java
/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
but cannot find it when click new sdk and navigate folders
just did it i think
ok i imported it
how do i deploy?
 
1:58 PM
There is IntellijIDEA Plugin when you click on new
IntellijIDEA Plugin SDK
same command on terminal
 
OE1
so i dont import?
ah ok sorry
i got what you mean
 
with this one ./gradlew
 
OE1
should I also add a SDK plugin apart from jdk?
 
ya add it
 
OE1
I do not understand what step I should take now actually
where do I find it?
 
2:02 PM
It automatically give you that path
 
OE1
ah right
ok did it
 
Is your run config. is ready ?
run your desktop module through IDE if all ready
 
OE1
I have imported the project now, and it says its refreshing the project
where will run config be?
 
There is Edit Config button in navigation bar
 
OE1
after import it said build successful (i didnt press anything for build it started automatically i guess)
 
2:07 PM
Select Run/Debug configuration
it's ok it refreshing and automatically build your project that mean added required dependency
 
OE1
so I clicked run at the navigation bar and I there are "Run" and "Debug" choices. when I press Debug it addes a box in the middle of the program
there is edit configurations on that
should I click edit configurations for debug or run?
 
Ya there is Dialog Run/Debug Configuration
Then After Add New Config(+)
Select Application
 
OE1
ok I did it
 
Main Class : Desktop Launcher
 
OE1
done
 
2:12 PM
Working Dir. is your assets folder of android module
Use class path module : desktop
 
OE1
done
 
Then Apply and OK
 
OE1
done
 
./gradlew desktop:dist
 
OE1
it runs the game as usual
 
2:15 PM
open your terminal
 
OE1
already ready, im on my main project directory
now do I do ./gradlew desktop:dist
 
./gradlew desktop:dist
 
OE1
done, generated the jar
 
run it
 
OE1
jar behaves like before, the first page is ok, when I switch to another page with assets it fails unless I move it to another folder with assets
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load dependencies of asset: SelectEffect.png
 
2:20 PM
I think there is some problem in your code
 
OE1
error message is still this when I run the game from terminal and switch to a different page with assets
 
need your code
 
OE1
sure
Assets.loadSprite("mainMenu.png", "mainMenu");
Assets.loadSprite("menuBar.png", GameConstants.menuBar);
this is how I upload the images in the first page
I have a class called Assets
//Get a sprite
public static Sprite loadSprite(String path, String label){
TextureParameter param = new TextureParameter();
param.minFilter = TextureFilter.MipMapLinearNearest;
param.genMipMaps = true;

Texture texturesheet;
Sprite tempsprite;
manager.load(path, Texture.class, param);
manager.finishLoading();
texturesheet = manager.get(path, Texture.class);
texturesheet.setFilter(TextureFilter.MipMapLinearLinear,TextureFilter.Linear);
tempsprite = new Sprite(texturesheet);
if(SpriteMap.containsKey(label)){System.out.println("WARNING- Label: "+label+" is already used in SpriteMap. Its now re
 
Some more code
 
OE1
this is how I load sprites
 
2:22 PM
just a minute i figure out
Assets is your class
 
OE1
sure (this is where I define manager: public static AssetManager manager = new AssetManager();)
yes
 
never create AssetManager static
 
OE1
oh, why?
 
I'll tell you later but now this is not the problem
 
OE1
sure
 
2:25 PM
Show my your code of Assets class
 
OE1
package Functions;

import Abilities.*;
import Functions.*;
import Objects.*;
import Screens.*;

import java.util.ConcurrentModificationException;
import java.util.HashMap;
import java.util.Map;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.assets.loaders.TextureLoader.TextureParameter;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.g2d.Animation;
ah and I have this at the dispose method of my first login screen
done = false;
returnedMessage = "";
Assets.Clear();
shapeRenderer.dispose();
batch.dispose();
font.dispose();
skin.dispose();
stage.dispose();
so Assets.Clear(); is called when I switch screens
but somehow this is okay for the background image I have
even the directory jar is run does not have the background image
 
are your using update() method on AssetManager
 
OE1
no?
 
is your dispose method called ?
 
OE1
yes
 
2:35 PM
Are you sure take a log and check
 
OE1
sure
 
if it called then from there you called your Assets.clear() and that will clear your AssetManager clear
so again you need to load all your assets to your assets manager
 
OE1
I just checked, and yes it is called
and it calls clear for asset manager
 
load on AssetManager only keep your asset in queue only . The AssetManager does not yet load anything. To kick this off we have to call AssetManager#update() continuously, say in our ApplicationListener#render() method:
Your AssetManager got cleared then have you again load your assets to assetManager
 
OE1
so should I add manager.update to all of my screens?
or should I also remove the part that calls manager.clear
 
2:39 PM
Firstly don't call Assets clear method and run your project
through IDE
triangular green button
Check is it work perfectly on different screen
through all over your game
 
OE1
done
it works
 
now buld you jar
*build
 
OE1
still had
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load dependencies of asset: SelectEffect.png
should I also add manager.update now?
 
ya sure
how it run through IDE without loading assets into AssetManager
 
OE1
without loading the assets?
you mean for the entire game I should just comment out the parts wher I call loadSprite etc?
 
2:48 PM
update() method load assets into AssetManager. and you're calling that
 
OE1
ah ok
ERROR- Label: mainMenu doesnt exist in SpriteMap.
Exception in thread "LWJGL Application" java.lang.NullPointerException
at com.badlogic.gdx.graphics.g2d.SpriteBatch.draw(SpriteBatch.java:646)
at Screens.LoginScreen.DrawStatic(LoginScreen.java:380)
at Screens.LoginScreen.render(LoginScreen.java:353)
at com.badlogic.gdx.Game.render(Game.java:46)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:223)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:124)
package Screens;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import io.socket.client.Socket;
import Abilities.*;
import Functions.*;
import Objects.*;
import Screens.*;
import godball.pack.GodballMain;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL30;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Pixmap;
I added Update function for Assets, and called it continuously at render part
and commented out the parts where I call loadSprite etc
 
you should initialize your object in show method
rather than constructor
 
OE1
you mean all my objects? do you think this is causing the problem?
 
no no this is only recommendation
wait 2 minute
 
OE1
sure, thanks for recommendation :) I know I should definitely reorganize some stuff in my code
 
3:05 PM
Assets.loadSprite(path, label);
Are you there
??
 
OE1
yes
sorry just saw the notification
what is with loadSprite?
 
it's ok
As i check you load your assets by calling GetAssets() method in LoginScreen
 
OE1
yes
 
After that many times loadSprite() called for different type of images and sounds
*images
path is the first argument of loadSprite
 
OE1
that is true?
 
3:12 PM
you always passing path one directory
or you can say first directory
suppose i have a folder pictures in assets folder and some images are in that pictures folder
then we need to pass pictures/ball.png as path in first argument
 
OE1
yes Im following you so far
(I dont have such a folder by the way)
 
have you any folder in assets?
or only image and sound type assets
 
OE1
only image & sound type assets
nothing else
 
If you're loading your assets through GetAssets() , you're not loading SelectEffect.png
 
OE1
I dont need it for login screen
I need it for another page and it is written on the GetAssets method of that screen
 
3:24 PM
where it is needed
 
OE1
package Screens;
import io.socket.client.Socket;
import Abilities.*;
import Functions.*;
import Objects.*;
import Screens.*;
import godball.pack.GodballMain;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL30;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Pixmap.Format;
here for example
 
3:39 PM
what is the size of SelectEffect.png
 
OE1
900x900
 
fine
what do you mean by this "without having to put all assets in the same folder?"
i think you are using SelcetEffect.png in one place comment that line and run
    batch.draw(Assets.getSprite(GameConstants.SelectEffect), selectEffectX, selectEffectY, 0, 0, selectEffectW, selectEffectH, 1, 1, 0);
 
OE1
i mean i want to create one file that i can send
i mean only one jar, without sending png's along with it
 
okay'
 
OE1
ok let me try without selecteffect
 
3:48 PM
I was thinking you got some problem due to number of different folder in your assets
 
OE1
no then I get problem for other assets
that assets are new assets that I didnt have in login screen
 
4:00 PM
Use Assets.getSprite() method after when AssetManager.update() return true
public static Sprite loadSprite(String path, String label){
TextureParameter param = new TextureParameter();
param.minFilter = TextureFilter.MipMapLinearNearest;
param.genMipMaps = true;

Texture texturesheet;
Sprite tempsprite;
manager.load(path, Texture.class, param);
manager.finishLoading();
texturesheet = manager.get(path, Texture.class);
texturesheet.setFilter(TextureFilter.MipMapLinearLinear,TextureFilter.Linear);
tempsprite = new Sprite(texturesheet);
if(SpriteMap.containsKey(label)){System.out.println("WARNING- Label: "+label+" is already used in SpriteMap. Its now replaced, which m
load all assets into manager and call update() method when it return true then get texture from manager and put into map
According to me problem is that data is not loaded into manager and you want to fetch from AssetManager
 
OE1
so I am trying to fetch too soon?
 
OE1
sure let me try
that makes sense actually
 
And why you are using finishLoading() it block main thread
in your loadSprite method you're loading Texture and just from next line you're getting from manager
 
OE1
yes? do you mean its inefficient?
and instead of running through the entire code, I tried the following to make sure I call update until it is ready:

public static Sprite loadSprite(String path, String label){
TextureParameter param = new TextureParameter();
param.minFilter = TextureFilter.MipMapLinearNearest;
param.genMipMaps = true;

Texture texturesheet;
Sprite tempsprite;
manager.load(path, Texture.class, param);
manager.finishLoading();
texturesheet = manager.get(path, Texture.class);
texturesheet.setFilter(TextureFilter.MipMapLinearLinear,TextureFilter.Linear);
but even when I wait for it using
while(manager.update()==false){}
it does not work independent of images I have
so it might not be about update after all
 
4:11 PM
Load all Assets of your screen (keep in queue by manager load() method)-> load by manager update method if update return true then get All Assets that is required by screen from manager and map your map
if(manager.update()){
}
 
OE1
I just realized something
which is pretty weird
 
OE1
I tried update again and it didnt work, then I wanted to check the normal version with only one change
I did this:
that is what I normally have in login screen getAssets():
//BackGround
Assets.loadSprite("mainMenu.png", "mainMenu");
Assets.loadSprite("menuBar.png", GameConstants.menuBar);
I just added
Assets.loadSprite("SelectEffect.png" , GameConstants.SelectEffect);
because I know it works with mainMenu and menuBar
and it stopped working
 
have you edit your loadSprite method
 
OE1
so for some reason, if I try to get SelectEffect.png anywhere in the code it fails (unless I add it to same folder)
no I reverted back to original (I tried both ways)
I do not understand what can be different between mainMenu.png and SelectEffect.png as they are both in the same folder
android assets that is
 
4:20 PM
may be size matter
mainMenu.png take less time to load then SelectEffect.png
 
OE1
yeah, selectEffect has considerable more size actually
~800kB vs 20kB
 
size in dimension
 
OE1
690x465 vs 900x900
 
Deployment process is fine . According to me problem is in AssetManager
 
OE1
By the way I narrowed down the assets to have a clue
and it seems like only two images and 3 sounds have those problem
they are either large by size or dimension I guess
 
4:33 PM
According to me that is not loaded into Assets
use this to check asset are in manager or not manager.containsAsset(..)
 
OE1
no they are not
so it fails to get them
I dont know for sounds but for images it might be the dimension
 
OE1
4:51 PM
I will give a break for today, you can always write if you have any new ideas. Thanks for all your effort, really
 

last day (14 days later) »