为什么我只在Xamarin上的SpriteBatch.End()上获得“IndexOutOfRange”异常?

时间:2016-08-06 23:31:10

标签: c# xamarin xna monogame

我正在使用MonoGame制作游戏,它在Windows上运行完美,但在尝试使用Xamarin将其移植到Android时,我在调用spriteBatch.End()时会得到一个“IndexOutOfRange”。

这是堆栈:

System.Diagnostics.Debugger.Mono_UnhandledException_internal() in 
System.Diagnostics.Debugger.Mono_UnhandledException(System.IndexOutOfRangeException ex) in /Users/builder/data/lanes/3540/1cf254db/source/mono/mcs/class/corlib/System.Diagnostics/Debugger.cs:122
object.a7d49486-d0dd-45db-8010-9608e82e96bd( arg0,  arg1) in 
Microsoft.Xna.Framework.Graphics.VertexDeclaration.Apply(Microsoft.Xna.Framework.Graphics.Shader shader, System.IntPtr offset) in 
Microsoft.Xna.Framework.Graphics.GraphicsDevice.PlatformDrawUserIndexedPrimitives<Microsoft.Xna.Framework.Graphics.VertexPositionColorTexture>(Microsoft.Xna.Framework.Graphics.PrimitiveType primitiveType, Microsoft.Xna.Framework.Graphics.VertexPositionColorTexture[] vertexData, int vertexOffset, int numVertices, short[] indexData, int indexOffset, int primitiveCount, Microsoft.Xna.Framework.Graphics.VertexDeclaration vertexDeclaration) in 
Microsoft.Xna.Framework.Graphics.GraphicsDevice.DrawUserIndexedPrimitives<Microsoft.Xna.Framework.Graphics.VertexPositionColorTexture>(Microsoft.Xna.Framework.Graphics.PrimitiveType primitiveType, Microsoft.Xna.Framework.Graphics.VertexPositionColorTexture[] vertexData, int vertexOffset, int numVertices, short[] indexData, int indexOffset, int primitiveCount, Microsoft.Xna.Framework.Graphics.VertexDeclaration vertexDeclaration) in 
Microsoft.Xna.Framework.Graphics.SpriteBatcher.FlushVertexArray(int start, int end, Microsoft.Xna.Framework.Graphics.Effect effect, Microsoft.Xna.Framework.Graphics.Texture2D texture) in 
Microsoft.Xna.Framework.Graphics.SpriteBatcher.DrawBatch(Microsoft.Xna.Framework.Graphics.SpriteSortMode sortMode, Microsoft.Xna.Framework.Graphics.Effect effect) in 
Microsoft.Xna.Framework.Graphics.SpriteBatch.End() in 
SoulEngine.Engine.Draw(Microsoft.Xna.Framework.GameTime gameTime) in D:\Cloud\Development\Code\Soul\SoulEngine_Android\A_Core\Engine.cs:70
Microsoft.Xna.Framework.Game.DoDraw(Microsoft.Xna.Framework.GameTime gameTime) in 
Microsoft.Xna.Framework.Game.Tick() in 
Microsoft.Xna.Framework.AndroidGameWindow.OnUpdateFrame(Microsoft.Xna.Framework.MonoGameAndroidGameView sender, OpenTK.FrameEventArgs frameEventArgs) in 
OpenTK.GameViewBase.OnUpdateFrame(OpenTK.FrameEventArgs e) in /Users/builder/data/lanes/3540/1cf254db/source/opentk/Source/OpenTK/Platform/Android/GameViewBase.cs:313
OpenTK.Platform.Android.AndroidGameView.UpdateFrameInternal(OpenTK.FrameEventArgs e) in /Users/builder/data/lanes/3540/1cf254db/source/opentk/Source/OpenTK/Platform/Android/AndroidGameView.cs:349
OpenTK.Platform.Android.AndroidGameView.RunIteration(System.Threading.CancellationToken token) in /Users/builder/data/lanes/3540/1cf254db/source/opentk/Source/OpenTK/Platform/Android/AndroidGameView.cs:569
OpenTK.Platform.Android.AndroidGameView.StartThread.AnonymousMethod__0(object _) in /Users/builder/data/lanes/3540/1cf254db/source/opentk/Source/OpenTK/Platform/Android/AndroidGameView.cs:459
Android.App.SyncContext.Send.AnonymousMethod__0() in /Users/builder/data/lanes/3540/1cf254db/source/monodroid/src/Mono.Android/src/Android.App/SyncContext.cs:32
Java.Lang.Thread.RunnableImplementor.Run() in /Users/builder/data/lanes/3540/1cf254db/source/monodroid/src/Mono.Android/src/Java.Lang/Thread.cs:36
Java.Lang.IRunnableInvoker.n_Run(System.IntPtr jnienv, System.IntPtr native__this) in /Users/builder/data/lanes/3540/1cf254db/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Java.Lang.IRunnable.cs:81
object.a7d49486-d0dd-45db-8010-9608e82e96bd( arg0,  arg1) in 

这里是错误所在的代码行,我只是在测试一些东西并绘制一个1x1的白盒子:

        68  ink.Begin();
        69  ink.Draw(blankTexture, new Rectangle(0, 0, 1, 1), Color.White);
        70  ink.End();

我想再次提一下,这在Windows上没有问题。

0 个答案:

没有答案