GraphicsDevice.VertexDelcaratio
Good Day Mates,
The only problem I seem to still have is that my program is in 2 seperate files,
The first program loads, sets the GraphicsDeviceManger and the like, but the second program with the draw code, doesn't seem to recognize GraphicsDevice.VertexDelcaration, etc... how do I pass this data to this other program or how should I go about this?
The error I'm getting is
Error 1 An object reference is required for the nonstatic field, method, or property 'Microsoft.Xna.Framework.Graphics.GraphicsDevice.VertexDeclaration.get' C:\BACKUP\SA\SimpleAnimationSample\SimpleAnimation\Carrier.cs 159 25 RotorheaD
Thanks again Mates,
LBB
GraphicsDevice isn't a static class, it's a member of the Game class. Therefore, if you wish to access it outside of the Game class, you need to pass it as a parameter somehow, either in the constructor or through whichever method you need it. For example:
class Game{ void Draw() { OtherClass c = new OtherClass(); c.DoSomething(GraphicsDevice); }}class OtherClass{ public void DoSomething(GraphicsDevice device) { device.VertexDeclaration = whatever; }}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement