Nullpointer exception when loading texture in libgdx - libgdx

I get a nullpointer exception when loading splash.png. It works running on android, but throws an exception when running on the desktop even though the file is in android's asset folder and exists in the desktop's asset folder.
Any ideas what's happening? I did clean, restarted eclipse, re-imported the projects...
public class MainMenuScreen implements Screen {
#Override
public void show() {
Texture background = new Texture(Gdx.files.internal("data/splash.png"));
}
}

It should work like that, your assets folder is not correctly linked.
Taken from here:
https://github.com/libgdx/libgdx/wiki/Manual-project-setup#asset-folder-setup
"
-Click the Source tab, click Link Source, Browse, select the "assets" folder from your Android project and click OK.
-Specify "assets" for the folder name and click Finish then OK.
Note: If your desktop and Android projects are in the same parent folder, you can use "PARENT-1-PROJECT_LOC/gamename-android/assets" for the location of the linked assets folder, where "gamename-android" is the name of your Android project. This is better than a hard-coded path if you plan on sharing your projects with others."

Related

SWFLoader Working in Air Project but not Web Project

I have been developing a Web type Flex project in Flash builder. In this project I have been trying to load a swf file using the SWFLoader. I have had trouble getting the debugger working, so I have instead created an identical Air project that I can run and debug with (I keep it up to date with a script). I have successfully loaded the swf file in my Air project with no trouble. But, when I went to test this in my Web project, the SWFLoader does not seem to work, I just get a blank area where my SWFLoader element should display the loaded swf file.
private function get_swf_file_binary_amf(event:ResultEvent):void {
Alert.show("SWF Returned");
var decoder:Base64Decoder=new Base64Decoder();
decoder.decode(event.result);
var swf_bytes:ByteArray=decoder.toByteArray();
var context:LoaderContext=new LoaderContext();
context.allowLoadBytesCodeExecution=true;
context.parameters = {myval: "test_string"};
swf_loaded_file.loaderContext = context;
swf_loaded_file.addEventListener(Event.COMPLETE, loadComplete);
swf_loaded_file.load(swf_bytes);
}
private function loadComplete(completeEvent:Event):void{
trace("load Complete")
}
Above is the code that works in my Adobe Air project. I am receiving the binary data of my swf file and converting it into a ByteArray, not using the URLLoader like so many example suggest. Could this be the cause of my problems when I try to run this in my Web project?
Edit/Update: I have found the particular line where the Web project fails:
context.allowLoadBytesCodeExecution=true;
I am still not sure why my Web project does not like this line, yet my Air project doesn't care.
I have removed the accursed line:
context.allowLoadBytesCodeExecution=true;
This seems to have fixed the problem. I am not even quite sure what this line does, I had just carried it over from a tutorial. Getting rid of it didn't seem to break anything that worked in my Air project, so I think that solved my problem.

storyboard file main~iphone.storyboardc was not found error when trying to submit binary to itunes connect

When I try to submit to the app store from xcode, I get this error for both Main~ipad.storyboardc and Main~iphone.storyboardc:
"ERROR ITMS-90029: "Storyboard file 'Main~iphone.storyboardc' was not found. Please ensure the specified file is included in the bundle with any required device modifiers appended to the filename."
I've looked at all similar questions posted to stackoverflow and tried their suggestions with no luck.
My app is for iphone ONLY, does not use storyboard, and runs perfectly well on all iphone simulators without errors.
Now when I go back to a snapshot of when the project ran well on simulators, the project no longer runs...I get error "Failed to instantiate the default view controller for UIMainStoryboardFile 'Main' - perhaps the designated entry point is not set?"
The problem was that I deleted the Main.Storyboard file from my project. I thought it would be OK to delete that file since I wasn't using it.
The issue for me was that I switched my supported devices from universal to iPad only. I had also changed the name of the Main.storyboard file but after I had updated the supported devices. So the Main storyboard file base name entry in the info.plist file was still Main.storyboard.
Deleting the entire row for Main storyboard file base name and leaving Main storyboard file base name (iPad) in the info.plist file fixed the issue.
Since your project is iPhone only just make sure to remove Main storyboard file base name (iPad) completely.

Chrome is retrieving old code, even clearing all history

I have a web site, which uses external dll code .
The dll is not part of the web site. (It is Dynamics AX 2012 CIL, but I think this no matter).
The web site has dll, that uses that code in Rest technique (I use MCV4 for VS 2010, and Rest API client tool for chrome).
The code run fines, but when I do some changes, the changes don't reflect on the site (I see the old behavior of code).
I clean all of the history in chrome - same problem.
For my own user: When I installed Firefox + Rest tool for Firefox - things work properly for Firefox (with the changes reflect on the site). For Chrome - still I had the problem.
That happened for specific users (other users - doesn't have any problem at all).
So, I presume that's may be some declarations on web.config that uses caches between the server and the browser.
Am I right? How this the caches between the server and the browser is called?
Is that a problem in chrome, or something I need to declare on web.config (or in C#)?
How can I declare that cache will be refreshed only when I uploaded a new code to site (A specific time stamp on web.config, or something like that)?
The code of mine in webapiconfig.cs (it is MCV4 for VS 2010):
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
FormUrlEncodedMediaTypeFormatter f;
config.Formatters.Clear();
config.Formatters.Add(new JsonMediaTypeFormatter());
f = new FormUrlEncodedMediaTypeFormatter();
f.SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/x-www-form-urlencoded"));
config.Formatters.Add(f);
}
}
What shall I write in C# or in output caching IIS configuration, as on site:
http://www.iis.net/learn/manage/managing-performance-settings/walkthrough-iis-output-caching#05
Thanks :)
the DLL runs on the server, therefore it is the SERVER cache you need to clear, not you browser cache.
you're talking C# so I guess you're using IIS
Click on the server name then go to output caching.
Click Add Cache Rule then type the extensions - .dll
and follow the prompts to disable caching for this extension.

LWJGL Sound manager issue

I have been working on the Asteroids Game example code that they give in the tutorials section of the wiki and I ran into a strange error.
The code works just fine in my development environment, Eclipse. The game runs without error and exits normally.
I go through the export process in the file menu and create an executable jar that when run with this batch file code
java -Djava.library.path=D:\Tools\lwjgl-2.8.4\lwjgl-2.8.4\native\windows -jar SpaceInvaders.jar
Starts the display and the fails when it trys to load a wav file. Giving this error.
Exception in thread "main" java.lang.NullPointerException
I traced to where in the code this is happening and it is at the location where the wavs are being loaded. Apprently outside of the environment it can't locate the files even though they are right next to the code? All my wav files and gif files are just in the same directory as the java class files right now so calling them from the code looks likes this:
http://i.imgur.com/2gnN1.png
Searching for stuff on google it tells me to zip them into a seperate file and then import to the class folder and refrence from there. I was wondering if there was a way to keep the files inside my main jar file instead of having to create a seperate entity.
Thanks for the replys! Let me know if more information is needed.
You may want to consider using a higher-level API, such as the 3d soundsystem from paulscode. SoundSystem can read from inside the jar(like you are asking), and automatically switch to java sound if LWJGL sound isn't supported on the current hardware.

When I zip up my demo FlashDevelop project..why does it break?

I built an AS3 image gallery using FlashDevelop.
Before I zip up the application, I can run the image gallery in my browser by simply opening the index.html for the project. Everything works perfectly.
I then zip up the project as proj-0.1.2.zip using winrar.
I then unzip this newly created zip and try to load the application using the project index.html like above. The gallery doesn't function properly. From seeing what happens, it appears as though the image metadata is not present(but I'm not sure, see below).
There are other applications as well that are broken. Videos don't load. If an application doesn't depend on any external assets then everything looks fine.
Another thing..If I then build the FlashDevelop project and republish the swf..then it works in the index.html like I want. What is going on here?
I want people to be able to fire up my demo apps out of the box by just running the index.html. If that doesn't always work and they have to figure out that they need to rebuild the SWF then that's pretty bad.
I don't think zipping is the problem, I think moving to a different folder is a problem.
I assume you are running this index.html on your local PC, and not on a webserver?
By default, Flash cannot access from a local SWF to load other local files. However, FlashDevelop / Flash CS3 / Flex Builder, in order to get around this restriction, set some flags in the flash player telling him "This SWF is a trusted SWF, allow him to open local files". But it's based on the exact location of the SWF.
There's a setting somewhere in the compiler, that sets a flag in the SWF saying "This SWF can access local data", but there's one downside: It blocks all access to network resources. So it's either/or: access local data, OR access network resources (anything that goes over HTTP, Socket, etc). I'm not sure where this setting is offhand. It may be that the default setting for Flash CS3 is different than the default setting for FlashDevelop.
Anyway, the easy way to avoid all this issue is to not run the file locally. Put it on your webserver before testing.