问题描述
我开始将我的 LIBGDX 应用程序移植到 IOS.我使用 libgdx 的 Xamarin studio 端口在 IOS 上运行我的应用程序.我移植成功,但应用程序无法加载 TextureAtlas File &Iphone 模拟器中的 BitmapFont 文件.
I started porting my LIBGDX appliction to IOS. I Used Xamarin studio port of libgdx to run my application on IOS. I was successful in porting but the application failed to load the TextureAtlas File & BitmapFont File in Iphone Simulator.
我尝试的代码是
...
AssetManager assetManager = new AssetManager();
assetManager.load("packer/help.txt", TextureAtlas.class);
if (assetManager.update()) {
}
...
上面的代码在桌面和安卓上运行良好,但在 Iphone Simulator 上运行时,我得到了以下日志.
The above code is running fine for me on Desktop and android but while running it on Iphone Simulator I got the following log.
Unhandled Exception:
0 iosgame 0x000f4f7e mono_handle_exception_internal_first_pass + 2190
1 iosgame 0x000f69c2 mono_handle_exception_internal + 1602
2 iosgame 0x000f750f mono_handle_exception + 47
3 iosgame 0x0013a662 mono_x86_throw_exception + 306
4 ??? 0x0b730f8f 0x0 + 192089999
at com.badlogic.gdx.assets.AssetManager.update () [0x0009c] in /Users/badlogic/jenkins/workspace/libgdx-mac/gdx/src//com/badlogic/gdx/assets/AssetManager.java:346
at (wrapper synchronized) com.badlogic.gdx.assets.AssetManager.update () <IL 0x00009, 0x0002c>
at com.racing.gold.Screen.SplashScreen.update (single) [0x0001f] in /Users/Vikalp/Downloads/libgdx-nightly-20130609/Generated Project/my-gdx-game/src/com/racing/gold/Screen/SplashScreen.java:80
at com.racing.gold.Game.render () [0x0000d] in /Users/Vikalp/Downloads/libgdx-nightly-20130609/Generated Project/my-gdx-game/src/com/racing/gold/Game.java:48
at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <IL 0x00056, 0x000a4>
at MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38
at com.ios.temp.project.Application.Main (string[]) [0x00000] in /Users/Vikalp/Downloads/libgdx-nightly-20130609/Generated Project/my-gdx-game-ios/Main.cs:33
at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00049, 0x00077>
30 iosgame 0x0006f462 mono_jit_runtime_invoke + 722
31 iosgame 0x001d34de mono_runtime_invoke + 126
32 iosgame 0x001d76d4 mono_runtime_exec_main + 420
33 iosgame 0x001dcac5 mono_runtime_run_main + 725
34 iosgame 0x000ccb65 mono_jit_exec + 149
35 iosgame 0x0026b494 main + 1988
36 iosgame 0x00068269 start + 53
2013-06-11 09:51:47.694 iosgame[567:c07] Unhandled managed exception: java.net.MalformedURLException: unknown protocol: file (com.badlogic.gdx.utils.GdxRuntimeException)
at com.badlogic.gdx.assets.AssetManager.handleTaskError (System.Exception t) [0x000bf] in /Users/badlogic/jenkins/workspace/libgdx-mac/gdx/src//com/badlogic/gdx/assets/AssetManager.java:512
at com.badlogic.gdx.assets.AssetManager.update () [0x0009c] in /Users/badlogic/jenkins/workspace/libgdx-mac/gdx/src//com/badlogic/gdx/assets/AssetManager.java:346
at (wrapper synchronized) com.badlogic.gdx.assets.AssetManager:update ()
at com.racing.gold.Screen.SplashScreen.update (Single deltaTime) [0x0001f] in /Users/Vikalp/Downloads/libgdx-nightly-20130609/Generated Project/my-gdx-game/src/com/racing/gold/Screen/SplashScreen.java:80
at com.racing.gold.Game.render () [0x0000d] in /Users/Vikalp/Downloads/libgdx-nightly-20130609/Generated Project/my-gdx-game/src/com/racing/gold/Game.java:48
at com.badlogic.gdx.backends.ios.IOSGraphics.OnRenderFrame (OpenTK.FrameEventArgs arg0) [0x00184] in /Users/badlogic/jenkins/workspace/libgdx-mac/backends/gdx-backend-iosmonotouch/src//com/badlogic/gdx/backends/ios/IOSGraphics.java:185
at OpenTK.Platform.iPhoneOS.iPhoneOSGameView.RunIteration () [0x000c1] in /Developer/MonoTouch/Source/monotouch/src/OpenGLES/OpenTK_1.0/Platform/iPhoneOS/iPhoneOSGameView.cs:830
at OpenTK.Platform.iPhoneOS.CADisplayLinkTimeSource.RunIteration () [0x00000] in /Developer/MonoTouch/Source/monotouch/src/OpenGLES/OpenTK_1.0/Platform/iPhoneOS/iPhoneOSGameView.cs:158
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.ios.temp.project.Application.Main (System.String[] args) [0x00000] in /Users/Vikalp/Downloads/libgdx-nightly-20130609/Generated Project/my-gdx-game-ios/Main.cs:33
我尝试将我的包扩展名从 .txt 更改为 .pack,但得到了相同的输出.
I Tried changing my pack extension from .txt to .pack but got the same output.
我无法在 Libgdx 论坛上找到解决方案.请赐教这个问题.
I wasn't able to find the solution on Libgdx forums. Please enlighten me on this problem.
推荐答案
嘿,我找到了问题.
当我们从 Xamarin Studio 运行应用程序时,它不会打包所有项目.它留下了一些文件,如文本文件、xmls 等.我们需要标记它们以将它们包含在应用程序中.将所有这些文件标记为捆绑资源.
When we make an app run from Xamarin Studio it does not pack all the items. It leaves some of the files like text files, xmls etc. We need to mark them to include them in app. Mark all these Files to be added as Bundle Resource.
这篇关于通过 AssetManager 加载时无法使用 libgdx 在 IOS 中加载 TextureAtlas 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!