Hi leute
ich arbeite grad an einem Projekt, welches ich geheim halten möchte ;D
Dort werden Module geladen
und Module sollen fähig sein, texturen zu zeichnen.
Dafür hab ich ein Game Libary Projekt gemacht, ein Content Projekt hizugefügt (zum Projekt und zur Mappe)
aber ich kann keine Textur laden, ich bekomm immer den Fehler, dass die Textur nicht nichts sein darf
Das interface:
Die Testklasse:
Und der aufruf:
ich arbeite grad an einem Projekt, welches ich geheim halten möchte ;D
Dort werden Module geladen
und Module sollen fähig sein, texturen zu zeichnen.
Dafür hab ich ein Game Libary Projekt gemacht, ein Content Projekt hizugefügt (zum Projekt und zur Mappe)
aber ich kann keine Textur laden, ich bekomm immer den Fehler, dass die Textur nicht nichts sein darf
Das interface:
VB.NET-Quellcode
- Namespace Modules
- Public Interface ModuleInterface
- ReadOnly Property Name As String
- Sub Initialize()
- Sub LoadContent()
- Sub UnloadContent()
- Sub Draw(ByVal spriteBatch As SpriteBatch, ByVal spriteFont As SpriteFont, ByVal graphicsDeviceManager As GraphicsDeviceManager)
- Sub Update(ByVal keyboardState As KeyboardState, ByVal mouseState As MouseState, ByVal gameTime As GameTime)
- End Interface
- End Namespace
Die Testklasse:
VB.NET-Quellcode
- Public Class Main
- Implements ************.Modules.ModuleInterface
- Private content As Content.ContentManager
- Private service As New GameServiceContainer
- Dim tex As Texture2D
- Public Sub Draw(spriteBatch As Microsoft.Xna.Framework.Graphics.SpriteBatch, spriteFont As Microsoft.Xna.Framework.Graphics.SpriteFont, graphicsDeviceManager As Microsoft.Xna.Framework.GraphicsDeviceManager) Implements ************.Modules.ModuleInterface.Draw
- spriteBatch.Draw(tex, New Vector2(0, 0), Color.White)
- End Sub
- Public Sub Initialize() Implements ************.Modules.ModuleInterface.Initialize
- content = New ContentManager(service)
- 'You have to change this after compiling
- content.RootDirectory = "********** Module (Content)"
- End Sub
- Public Sub LoadContent() Implements ************.Modules.ModuleInterface.LoadContent
- tex = content.Load(Of Texture2D)("File")
- End Sub
- Public ReadOnly Property Name As String Implements ************.Modules.ModuleInterface.Name
- Get
- 'The name of the module.
- 'Just for identification.
- Return "<ModuleName>"
- End Get
- End Property
- Public Sub UnloadContent() Implements ************.Modules.ModuleInterface.UnloadContent
- End Sub
- Public Sub Update(keyboardState As Microsoft.Xna.Framework.Input.KeyboardState, mouseState As Microsoft.Xna.Framework.Input.MouseState, gameTime As Microsoft.Xna.Framework.GameTime) Implements ************.Modules.ModuleInterface.Update
- End Sub
- End Class
Und der aufruf:
VB.NET-Quellcode
- ''' <summary>
- ''' This is called when the game should draw itself.
- ''' </summary>
- ''' <param name="gameTime">Provides a snapshot of timing values.</param>
- Protected Overrides Sub Draw(ByVal gameTime As GameTime)
- c_fpsCounter.Draw(gameTime)
- spriteBatch.Begin()
- 'Main Loop
- If b_isDebugEnabled Then
- Dim count As Integer = CInt(f_DebugFont.MeasureString("A").X)
- spriteBatch.DrawString(f_DebugFont, "********* Build " & My.Settings.BuildCount, New Vector2(0, 0 * count), Color.Black)
- spriteBatch.DrawString(f_DebugFont, c_fpsCounter.frameRate & " FPS", New Vector2(0, 1 * count), Color.Black)
- spriteBatch.DrawString(f_DebugFont, "Modules loaded: " & i_modulesLoaded, New Vector2(0, 2 * count), Color.Black)
- Dim w As Integer = 3
- For i As Integer = 0 To s_moduleListNames.Count - 1
- spriteBatch.DrawString(f_DebugFont, s_moduleListNames.Item(i), New Vector2(0, w * count), Color.Black)
- w += 1
- Next
- End If
- For Each m As ***********.Modules.ModuleInterface In module_list
- m.Draw(spriteBatch, f_DebugFont, graphics)
- Next
- 'End of main loop.
- spriteBatch.End()
- MyBase.Draw(gameTime)
- End Sub
Always code as if the person who ends up maintaining your code is a violent psychopath who knows where you live.
BeryJu.org BeryJu.org/Blog
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „JensMn“ ()