2012-03-19 232 views
0

由於某種原因,當我嘗試渲染它們時,紋理看起來很奇怪。 XNA抓住最下面一排像素並向上拉伸。XNA 2D紋理無法正常渲染

實時影像:The original image

什麼是呈現:The rendered image

我用這個功能來呈現我的形象

// NOTE: c is a instance of my control class that contains textures etc. 

Rectangle rect = c.Texture.Bounds; 
rect.Offset(Convert.ToInt16(c.position.X), Convert.ToInt16(c.position.Y)); 

spriteBatch.Draw(c.Texture, c.position, rect, Color.White, 0F, new Vector2(), 1F, SpriteEffects.None, 1F); 

有人可以告訴我什麼,我做錯了嗎?

在此先感謝。

回答

1

看起來好像你在某種程度上搞砸了紋理座標(即整個sprite使用紋理的下邊框,同時也搞亂了水平縮放。你打算如何調用rect.Offset()?矩形描述了什麼部分如果這不是原因或解決方案,我們需要更多信息,例如v.Xv.Y是什麼

+0

我複製了我的代碼錯誤,將vX更改爲正確的值 – Mechazawa 2012-03-19 10:19:53

+0

我發現我的問題,它與rect.Offset() – Mechazawa 2012-03-19 11:30:31