Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am following a textbook tutorial for a game called "SquareChase"; my professor wants the class to make our own modifications. I'm using a PNG tileset for the squares' colors. To make troubleshooting easier, I created a separate Square class. I have two errors in the main game code. They are both in the block of code below:

C#
spriteBatch.Draw(squareTexture
                 currentSquare,
                 Square.Colors[playerScore%27]);
spriteBatch.End();
asd
<b>Error 1:</b> The best overloaded method match for 'Microsoft.Xna.Framework.Graphics.SpriteBatch.Draw(Microsoft.Xna.Framework.Graphics.Texture2D, Microsoft.Xna.Framework.Rectangle, Microsoft.Xna.Framework.Color)' has some invalid arguments

Error 2:; Argument 3: Cannot convert from "string" to "Microsoft.Xna.Framework.Color"

The book I'm working in is called "XNA 4.0 Game Development by Example"; it's published by Packt Publishing
Posted
Updated 25-Aug-11 16:27pm
v3

1 solution

The documentation is the source that can help you the most SpriteBatch.Draw[^]

From the error message I can see that Square.Colors[] is an array of strings, but you're setting the color parameter to a string, but it only accepts Color[^] so you need to convert your string to Color[^]

If your book tells you that you can use a string then you should go ask for your money back.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900