Sponsors

Go Back   Zune Boards > Zune Discussions > Zune Games > Development Discussions

New Member?


Register Zunecentive FAQ Members List Calendar Search Today's Posts Mark Forums Read

Development Discussions All developers who are coding games may stop by here for any help, suggestions, and everything development related.

Reply
 
LinkBack Thread Tools
Old 06-07-2008, 10:47 PM   #1 (permalink)
Experienced Zuner
 
Join Date: May 2008
Posts: 207
Reputation: 12
$zB: 170
Donate
Default reference a non-static field?? and a couple more questions

I was trying to edit ScrambledAlbums so that it would show the size of the puzzle when completed, but when i change:

Code:
string winText = "WIN!";
to:

Code:
string winText = gridSize.ToString + " Completed!";
it gives me this error:
Error 1 A field initializer cannot reference the non-static field, method, or property 'ScrambledAlbums.GamePlayScreen.gridSize'

here's the code above it (and a little below):

Code:
using System;
using System.Collections.Generic;
using System.Text;
using Satellite.Screens;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Satellite.Input;
using Microsoft.Xna.Framework.Input;

namespace ScrambledAlbums
{
	public class GamePlayScreen : GameScreen
	{
		MenuScreen menuScreen;

		MediaLibrary ml = new MediaLibrary();
		List<Album> albumsWithArt = new List<Album>();
		Random rand = new Random();
		ScrambledArt puzzle;
		int gridSize;
		SpriteFont winFont, continueFont;
		bool isSolved = false;
		string winText = gridSize.ToString + " Completed!";
		string continueText = "Generate New Puzzle";
		string newText = "New";
		string optionsText = "Options";
		string quitText = "Quit";
I also want to add a zoom function. To do this I will have to remap two of the buttons (back and play/pause) and add an option in the zBlade menu to go back to the menu and to generate a new puzzle. What I want the zoom to do is press the back button and it will zoom you in to zoom setting one, press it again and it zooms in a little more, press it again and it goes back to normal. While zoomed in I want to press the play button to enter scrolling mode. While in scrolling mode you use the touch pad to move in any direction.

You're probably wondering why I want a zoom button. Well, it's because I do puzzles bigger than 10x10 (I already figured out how to do that), and my record is 12x12. If I can get zoom I will be able to do MUCH bigger puzzles

One more thing I want to do is add picture support, but have no idea how to do that...

Here is a link to the dl: http://nick.gravelyn.com/2008/05/21/...eal-attempt-2/

Please try to answer at least the first question, it should be easy enough =P

P.S. I know I forgot something, I'll add it in later.

And TY in advance to all who answer!



cable729 is offline   Reply With Quote
Remove Advertisements Sponsored Links
Advertisement
 
Old 06-07-2008, 11:13 PM   #2 (permalink)
Jr. Member
 
SimReality's Avatar
 
Join Date: May 2008
Location: Seattle, WA
Posts: 398
Reputation: 60
$zB: 341
Donate
Default

That's because that variable isn't initialized at that point in code. On top of that you are trying to call ToString without parenthesis when it should be gridSize.ToString(). So what you'll want to do is something like this. First set the variable to this:

Code:
string winText = "{0} Completed!";
Then in the draw code where it's being used, you use string.Format to replace the {0} with the gridsize:

Code:
string realWinText = string.Format(winText, gridSize);
SpriteBatch.DrawString(
	winFont,
	realWinText ,
	new Vector2(120, 265) - winFont.MeasureString(realWinText) * .5f,
	Color.White);
and you should be good to go.
__________________
Nick Gravelyn
Microsoft MVP - DirectX/XNA

To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.



SimReality is offline   Reply With Quote
Old 06-07-2008, 11:36 PM   #3 (permalink)
Experienced Zuner
 
Join Date: May 2008
Posts: 207
Reputation: 12
$zB: 170
Donate
Default

I can't find where it's being used in the draw code. Can you have a look at it?



cable729 is offline   Reply With Quote
Old 06-07-2008, 11:51 PM   #4 (permalink)
Jr. Member
 
SimReality's Avatar
 
Join Date: May 2008
Location: Seattle, WA
Posts: 398
Reputation: 60
$zB: 341
Donate
Default

Right click on the winText variable and select Find All References. That will pop up a window telling you everywhere it's used. That should help you find it in the code. It's just towards the bottom in the Draw method.
__________________
Nick Gravelyn
Microsoft MVP - DirectX/XNA

To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.



SimReality is offline   Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT -8. The time now is 02:19 AM.

 
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0 RC8
vB Ad Management by =RedTyger=
(C) ZuneBoards 2006-2007