我不了解这些XNA错误;请帮忙! [英] I don't understand these XNA Errors; Please help!

查看:98
本文介绍了我不了解这些XNA错误;请帮忙!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注一个名为"SquareChase"的游戏的教科书教程;我的教授希望全班做自己的修改.我正在为正方形的颜色使用PNG拼贴集.为了简化故障排除,我创建了一个单独的Square类.我的主要游戏代码有两个错误.它们都在下面的代码块中:

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:

spriteBatch.Draw(squareTexture
                 currentSquare,
                 Square.Colors[playerScore%27]);
spriteBatch.End();

asd
< b>错误1:</b> ``Microsoft.Xna.Framework.Graphics.SpriteBatch.Draw(Microsoft.Xna.Framework.Graphics.Texture2D,Microsoft.Xna.Framework.Rectangle,Microsoft.Xna.Framework.Color)的最佳重载方法匹配有一些无效的参数

错误2:;参数3:无法从字符串"转换为"Microsoft.Xna.Framework.Color"

我正在写的书叫做"XNA 4.0 Game Development by Example";它由Packt Publishing发布.

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

推荐答案

该文档是可以为您提供最大帮助的资源. /en-us/library/microsoft.xna.framework.graphics.spritebatch.draw.aspx">SpriteBatch.Draw [ Color [ Color [
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.


这篇关于我不了解这些XNA错误;请帮忙!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆