iOS上的libgdx GdxRuntimeException无法加载文件 [英] libgdx on ios GdxRuntimeException couldn't load file

查看:105
本文介绍了iOS上的libgdx GdxRuntimeException无法加载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我决定将我的应用程序从Android迁移到iOS.应用程序使用libgdx库.我使用libgdx生成了ios子项目,并使用Xamarin Studio将其打开.所有图像都从my-project-android/assets/data链接.所有图像都设置了构建操作>内容.现在,每次从xamarin Studio运行项目时,我都会收到GdxRuntimeException不需要加载文件:data/background.png.该文件是我在应用程序中加载的第一张图像.

I decided to move my application from Android to iOS. Application use libgdx library. I generated ios subproject using libgdx and opened it using Xamarin Studio. All images are linked from my-project-android/assets/data. All images have set build Action > content. Now every time when run project from xamarin studio i get GdxRuntimeException Coldn't load file: data/background.png. This file is the first image which i load in my application.

我在Mac上使用模拟器和iPhone设备所做的所有操作.

All operation i have done on my mac both with simulator and iPhone device.

StackTrace:

StackTrace:

    com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: /data/background.png ---> System.Exception: unknown protocol: file
at java.net.URL..ctor (java.net.URL context, System.String spec, java.net.URLStreamHandler handler) [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at com.badlogic.gdx.graphics.Pixmap..ctor (com.badlogic.gdx.files.FileHandle file) [0x0004c] in /Users/badlogic/jenkins/workspace/libgdx-mac/gdx/src/com/badlogic/gdx/graphics/Pixmap.java:140
at com.badlogic.gdx.graphics.glutils.FileTextureData.prepare () [0x00052] in /Users/badlogic/jenkins/workspace/libgdx-mac/gdx/src/com/badlogic/gdx/graphics/glutils/FileTextureData.java:64
at com.badlogic.gdx.graphics.Texture.load (TextureData data) [0x00036] in /Users/badlogic/jenkins/workspace/libgdx-mac/gdx/src/com/badlogic/gdx/graphics/Texture.java:175
at com.badlogic.gdx.graphics.Texture.create (TextureData data) [0x0000d] in /Users/badlogic/jenkins/workspace/libgdx-mac/gdx/src/com/badlogic/gdx/graphics/Texture.java:159
at com.badlogic.gdx.graphics.Texture..ctor (com.badlogic.gdx.files.FileHandle file, com.badlogic.gdx.graphics.Format format, Boolean useMipMaps) [0x00060] in /Users/badlogic/jenkins/workspace/libgdx-mac/gdx/src/com/badlogic/gdx/graphics/Texture.java:133
at com.badlogic.gdx.graphics.Texture..ctor (com.badlogic.gdx.files.FileHandle file) [0x00001] in /Users/badlogic/jenkins/workspace/libgdx-mac/gdx/src/com/badlogic/gdx/graphics/Texture.java:122
at com.kaproel.trafficControlManager.MainMenuScreen..ctor (com.kaproel.trafficControlManager.trafficControl game) [0x00088] in /Users/Piotr/Developer/mono-iOS/trafficControl/src/com/kaproel/trafficControlManager/MainMenuScreen.java:64
at com.kaproel.trafficControlManager.trafficControl.create () [0x00024] in /Users/Piotr/Developer/mono-iOS/trafficControl/src/com/kaproel/trafficControlManager/trafficControl.java:32
at com.badlogic.gdx.backends.ios.IOSGraphics.OnLoad (System.EventArgs arg0) [0x00010] in /Users/badlogic/jenkins/workspace/libgdx-mac/backends/gdx-backend-iosmonotouch/src/com/badlogic/gdx/backends/ios/IOSGraphics.java:133
at OpenTK.Platform.iPhoneOS.iPhoneOSGameView.RunWithFrameInterval (Int32 frameInterval) [0x00041] in /Developer/MonoTouch/Source/monotouch/src/OpenGLES/OpenTK_1.0/Platform/iPhoneOS/iPhoneOSGameView.cs:694
at OpenTK.Platform.iPhoneOS.iPhoneOSGameView.Run () [0x00000] in /Developer/MonoTouch/Source/monotouch/src/OpenGLES/OpenTK_1.0/Platform/iPhoneOS/iPhoneOSGameView.cs:652
at com.badlogic.gdx.backends.ios.IOSApplication.FinishedLaunching (MonoTouch.UIKit.UIApplication uiApp, MonoTouch.Foundation.NSDictionary options) [0x0023e] in /Users/badlogic/jenkins/workspace/libgdx-mac/backends/gdx-backend-iosmonotouch/src/com/badlogic/gdx/backends/ios/IOSApplication.java:166
at at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38
at com.kaproel.trafficControlManager.Application.Main (System.String[] args) [0x00000] in /Users/Piotr/Developer/mono-iOS/trafficControl-ios/Main.cs:33

请给我相同的解决方案

代码窥探

  public MainMenuScreen(final trafficControl game) {
    this.game = game;
    this.stage = new Stage(0, 0,true);
    batch = new SpriteBatch();

    this.camera = new OrthographicCamera();
    this.camera.setToOrtho(false, 800, 480);


    texture = new Texture(Gdx.files.local("data/background.png")); // <!-- this line make runtime error

推荐答案

它可能是png优化的问题.您是否检查过此链接

its might be a problem of png optimization. Have you check this link

http://code.google.com/p/libgdx/wiki/IOSWIP

在此页面上阅读PNG优化.可能会对您有所帮助.

Read PNG optimization in this page. Might be that will help you.

这篇关于iOS上的libgdx GdxRuntimeException无法加载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆