有没有人对如何实现这一目标提出建议?
谢谢
解决方法 设置tileSize,然后在所需网格的大小上绘制纹理.这是一些重写的代码.这就是我开始使用2d数组生成tilemap的方法.
int tileSize = 32;Vector2 position = Vector2.Zero;Texture2D grIDTexture;int[,] map = new int[,]{ {1,1,},{0,{1,};
然后在draw函数中添加这样的东西:
for (int i = 0; i <= map.GetUpperBound(0); i++){ for (int j = 0; j <= map.GetUpperBound(1); j++) { int textureID = map[i,j]; if (textureID != 0) { Vector2 textureposition = new Vector2(i * tileSize,j * tileSize) + position; //Here you would typically index to a Texture based on the textureID. spriteBatch.Draw(grIDTexture,textureposition,null,color.White,Vector2.Zero,1.0f,SpriteEffects.None,0f); } }}总结
以上是内存溢出为你收集整理的silverlight – 如何使用XNA绘制动态网格全部内容,希望文章能够帮你解决silverlight – 如何使用XNA绘制动态网格所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)