473,386 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

C# - Developing Menu for XNA

Hi,

I'm having a problem developing a menu for a XNA project. I'm relatively new to C#.

The error that I'm getting is:

'Microsoft.Xna.Framework.Graphics.GraphicsDevice' is a 'type' but is used like a 'variable'

My class that has this error looks like this:

public override void LoadContent()
{
if (content1 == null)
content1 = new ContentManager(ScreenManager.Game.Services, "Content");
spriteBatch = new SpriteBatch(GraphicsDevice); -->This is where I get the error

myModel = content.Load<Model>("Models\\p1_wedge");
aspectRatio = (float)graphics.GraphicsDevice.Viewport.Width /
(float)graphics.GraphicsDevice.Viewport.Height;


//gameFont = content.Load<SpriteFont>("gamefont");
// A real game would probably have more content than this sample, so
// it would take longer to load. We simulate that by delaying for a
// while, giving you a chance to admire the beautiful loading screen.
//Thread.Sleep(1000);

// once the load has finished, we use ResetElapsedTime to tell the game's
// timing mechanism that we have just finished a very long frame, and that
// it should not try to catch up.
//ScreenManager.Game.ResetElapsedTime();

}

Please help
Feb 11 '08 #1
2 4086
Plater
7,872 Expert 4TB
You need to create an instance of the GraphicsDevice to pass in.
It would be like passing the word int in a function instead of say 42.
So create an instance of that type (possibly a derrived type) and then pass that in.
Feb 11 '08 #2
airl08
1
You have to initialize the Device Graphics Manager:
Expand|Select|Wrap|Line Numbers
  1. SharedGraphicsDeviceManager graphics = SharedGraphicsDeviceManager.Current;
and then passing the Graphics Device to the spriteBatch:
Expand|Select|Wrap|Line Numbers
  1. spriteBatch = new SpriteBatch(graphics.GraphicsDevice);
This is for Windows Phone, I guess is the same for Xbox.
Sep 11 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: BG | last post by:
We need to put a menu on a page on our website. The menu has to be in the vertical area of a frames page. Go to www.fqvictims.org . The menu choices on the left need to be categorized - and we...
2
by: Jackson Yap | last post by:
can someone kind enough to help me look at the attached html and js file? Why is it that the javascript menu could not work at www.apchosting.net but could work at...
1
by: Tim Johnson | last post by:
Hi all, I'm a little bit stuck, so wondering if anyone has encountered this issue before. I am developing a toolkit which is fully integrated in Visual Studio .NET, and so there are lots of...
2
by: sbu_c_student | last post by:
Hello.... I wanted to know if there was a way to write simple c code using visual .net? I really want to get used to the ide but i'm not sure how to.. Any comments will be appreciated... ...
6
by: VMI | last post by:
A client asked me to develop a site similar to http://www.luispachecorg.com and I don't know how much I should charge for it. The site will have about 6 pages, and one of the pages will include a...
0
by: Scott | last post by:
VB GUI source code for developing please see below web site. GUI Ver. 1.0 Is a very fancy pull down menu, toolbar multi tabbed GUI menu interface for any version of Visual Basic should run and ...
7
by: John | last post by:
I design the front end of my app in MyAppName-develop.mdb. When I want to deploy it I copy it and change the name to MyAppName.mdb. In the development mdb I want a different start up option then in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.