.. TRIEDEX VB.NET componet class templte For vb.net XNA ... Version 2
Imports
Microsoft.Xna.FrameworkImports
Microsoft.Xna.Framework.InputImports
Microsoft.Xna.Framework.ComponentsImports
Microsoft.Xna.Framework.GraphicsPublic
Class Template'******* Rename this to the name of your classInherits GameComponentImplements IGraphicsDeviceService#
Region"...................... Core overrides inherited from GameComponent ................................. "'****************************************************************************'// Called when the GameComponent needs to be drawn. Override this method with component-specific draw code.'****************************************************************************''' <summary></summary>PublicOverridesSub Draw()EndSub'****************************************************************************'// Called when the GameComponent needs to be updated. Override this method with component-specific update code.'****************************************************************************PublicOverridesSub Update() EndSub'****************************************************************************'// Called after game initialization but before the first frame of the game.'****************************************************************************PublicOverridesSub Start()' //The line below is the key to components you can get the game object refrence this'the line is getting the graphics device so you can use it as need be!!!!mgraphics =
DirectCast(MyBase.Game.GameServices.GetService(GetType(IGraphicsDeviceService)), IGraphicsDeviceService)AddHandlerMe.[GraphicsDevice].DeviceReset,AddressOf graphics_DeviceResetAddHandlerMe.[GraphicsDevice].DeviceResetting,AddressOf graphics_DeviceResettingAddHandlerMe.[GraphicsDevice].DeviceResetting,AddressOf graphics_DeviceCreatedAddHandlerMe.[GraphicsDevice].Disposing,AddressOf graphics_DeviceDisposing'//Init component codeLoadContent()
EndSub'****************************************************************************'// Load Contenets here'****************************************************************************Sub LoadContent()'init componet objects hereEndSub'****************************************************************************'// ReleaseContent Contenets here'****************************************************************************Sub ReleaseContent()'Dispose of objects hereEndSub#
EndRegion#
Region"... Implementation of IGraphicsDeviceService......"Sub graphics_DeviceDisposing(ByVal senderAsObject,ByVal eAs System.EventArgs)ReleaseContent()
EndSubSub graphics_DeviceCreated(ByVal senderAsObject,ByVal eAs System.EventArgs)LoadContent()
EndSubSub graphics_DeviceResetting(ByVal senderAsObject,ByVal eAs System.EventArgs)ReleaseContent()
EndSubSub graphics_DeviceReset(ByVal senderAsObject,ByVal eAs System.EventArgs)LoadContent()
EndSubPublicReadOnlyProperty [GraphicsDevice]()As Microsoft.Xna.Framework.Graphics.GraphicsDeviceImplements IGraphicsDeviceService.GraphicsDeviceGetReturn mgraphics.GraphicsDeviceEndGetEndPropertyPublicEvent DeviceCreated(ByVal senderAsObject,ByVal eAs System.EventArgs)Implements Microsoft.Xna.Framework.Graphics.IGraphicsDeviceService.DeviceCreatedPublicEvent DeviceDisposing(ByVal senderAsObject,ByVal eAs System.EventArgs)Implements Microsoft.Xna.Framework.Graphics.IGraphicsDeviceService.DeviceDisposingPublicEvent DeviceReset(ByVal senderAsObject,ByVal eAs System.EventArgs)Implements Microsoft.Xna.Framework.Graphics.IGraphicsDeviceService.DeviceResetPublicEvent DeviceResetting(ByVal senderAsObject,ByVal eAs System.EventArgs)Implements Microsoft.Xna.Framework.Graphics.IGraphicsDeviceService.DeviceResettingPrivate mgraphicsAs IGraphicsDeviceService#
EndRegionEnd
Class
