1

I eventually couldn't get any further with my program due to the various shortcomings of VB.NET (bad audio support, no reading events in the middle of execution, very weak keyboard input, etc). So I tried SDL.NET 6.1.
Despite its terrible documentation, I was able to fix my code to use it and I love it!

But there's a problem. I don't know how to set up my application settings for it. The Startup Object definitely should be a class (the examples always are in classes, never modules), but a startup class specifically has to be a form! This is bad because SDL makes its own window via SetVideoMode; you don't need a form. So when the form constructor New() finishes, a useless form is created and you have two windows.

I tried placing a call to the game engine loop within New() so that the game starts up without New() ever finishing. The game runs normally, and this solves the "second window" problem... but it can't be closed! X button does nothing, calls to Events.QuitApplication or Me.Close are blatantly ignored, etc.

I'm stumped. It seems I need to set a non-form class as the startup object, but it won't let me.

Oh, by the way, it seems that there are two things called "SDL NET". To clarify, I'm using this one, which exists in the SdlDotNet namespace.

Oh, I forgot to mention, I also noticed that a lot of the examples have a line that says "[STAThread]". Is this is important?

EDIT: I've already received and accepted an answer for my question, but I want to tell other people what the problem is with exiting/closing the app, even though that wasn't my question:
While SDL.NET allows you to receive input and run other events without having to stop running logic, the application still cannot quit while logic is being run. So I find the best way to tell your SDL.NET application to Quit in the middle of running logic is to use the following TWO lines:

SdlDotNet.Core.Events.QuitApplication
End

Place these in the handler for the SdlDotNet.Core.Events.Quit event, as well as anywhere else you want your program to quit.

4

1 に答える 1

1

スタートアップ オブジェクトは間違いなくクラスである必要があります (例は常にクラスであり、モジュールではありません)。

これがあなたの間違いです。CLR の観点からは、クラスと VB モジュールの間に実際の違いはありません。それで、それをモジュールにしてMain、続けてください。クラスは必要ありません。クラスを使用する C# の例を見ていると思いますが、それは C# にモジュールのようなものがないためです。

[STAThread]おそらくSDLには何の違いもありません。これは UI アプリケーションにとって重要ですが (WinForms と WPF の両方で必要です)、SDL が COM 呼び出しを行うとは思わないため、スレッドがSTAであるかどうかは気にする必要はありません。これは、Visual Studio がMain既定で新しいプロジェクトに配置するものです。

于 2009-09-01T21:05:02.873 に答える