|
|
|
|||||||
| Development Discussions All developers who are coding games may stop by here for any help, suggestions, and everything development related. |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) |
|
Experienced Zuner
Join Date: May 2008
Posts: 207
Reputation: 12
Donate |
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!"; Code:
string winText = gridSize.ToString + " Completed!"; 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";
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!
|
|
|
|
| Remove Advertisements Sponsored Links | |
Advertisement |
|
|
|
#2 (permalink) |
|
Jr. Member
Join Date: May 2008
Location: Seattle, WA
Posts: 398
Reputation: 60
Donate |
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!";
Code:
string realWinText = string.Format(winText, gridSize); SpriteBatch.DrawString( winFont, realWinText , new Vector2(120, 265) - winFont.MeasureString(realWinText) * .5f, Color.White);
__________________
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.
|
|
|
|
|
|
#4 (permalink) |
|
Jr. Member
Join Date: May 2008
Location: Seattle, WA
Posts: 398
Reputation: 60
Donate |
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.
|
|
|
|
![]() |
| Thread Tools | |
|
|
| |