.. TRIEDEX VB.NET componet class templte For vb.net XNA ... Version 2

Imports Microsoft.Xna.Framework

Imports Microsoft.Xna.Framework.Input

Imports Microsoft.Xna.Framework.Components

Imports Microsoft.Xna.Framework.Graphics

PublicClass Template'******* Rename this to the name of your class

Inherits GameComponent

Implements 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_DeviceReset

AddHandlerMe.[GraphicsDevice].DeviceResetting,AddressOf graphics_DeviceResetting

AddHandlerMe.[GraphicsDevice].DeviceResetting,AddressOf graphics_DeviceCreated

AddHandlerMe.[GraphicsDevice].Disposing,AddressOf graphics_DeviceDisposing

'//Init component code

LoadContent()

EndSub

'****************************************************************************

'// Load Contenets here

'****************************************************************************

Sub LoadContent()

'init componet objects here

EndSub

'****************************************************************************

'// ReleaseContent Contenets here

'****************************************************************************

Sub ReleaseContent()

'Dispose of objects here

EndSub

#EndRegion

#Region"... Implementation of IGraphicsDeviceService......"

Sub graphics_DeviceDisposing(ByVal senderAsObject,ByVal eAs System.EventArgs)

ReleaseContent()

EndSub

Sub graphics_DeviceCreated(ByVal senderAsObject,ByVal eAs System.EventArgs)

LoadContent()

EndSub

Sub graphics_DeviceResetting(ByVal senderAsObject,ByVal eAs System.EventArgs)

ReleaseContent()

EndSub

Sub graphics_DeviceReset(ByVal senderAsObject,ByVal eAs System.EventArgs)

LoadContent()

EndSub

PublicReadOnlyProperty [GraphicsDevice]()As Microsoft.Xna.Framework.Graphics.GraphicsDeviceImplements IGraphicsDeviceService.GraphicsDevice

Get

Return mgraphics.GraphicsDevice

EndGet

EndProperty

PublicEvent DeviceCreated(ByVal senderAsObject,ByVal eAs System.EventArgs)Implements Microsoft.Xna.Framework.Graphics.IGraphicsDeviceService.DeviceCreated

PublicEvent DeviceDisposing(ByVal senderAsObject,ByVal eAs System.EventArgs)Implements Microsoft.Xna.Framework.Graphics.IGraphicsDeviceService.DeviceDisposing

PublicEvent DeviceReset(ByVal senderAsObject,ByVal eAs System.EventArgs)Implements Microsoft.Xna.Framework.Graphics.IGraphicsDeviceService.DeviceReset

PublicEvent DeviceResetting(ByVal senderAsObject,ByVal eAs System.EventArgs)Implements Microsoft.Xna.Framework.Graphics.IGraphicsDeviceService.DeviceResetting

Private mgraphicsAs IGraphicsDeviceService

#EndRegion

EndClass

[12846 byte] By [Tridex] at [2007-12-24]
# 1
Someone should start a VB XNA web site, I dont like VB that much so its not going to be me but its a good idea, or maybe they can run one for learnxna.com
aka_Big_Wurm at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 2

I have a website

http://www.tridexconsultants.co.uk/pages/DirectxClasses.htm

I will be uplading a lot of code over the week end, I have lots of classes I wish to share for 3d games development, escpecially the Vercor3, Matri4 e.t.c I have collected trhrough the years....

... Tridex....

Tridex at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...