开发者

Making a sprite always point to another sprite in XNA

I have a player sprite (playerTexture) and a crosshair sprite (crossTexture) in my game. I need to make the player sprite always face towards the crosshair.

Does anyone know how to do this? I have tried doing it myself 开发者_如何转开发but the math involved boggles my mind. I know there's a rotation parameter in the spriteBatch.Draw() method but I'm unsure how to use it.

Thanks!


rotating a sprite to following another sprite is mostly just triangle math. I was going to try and type up a good explanation, but then i found this posting - which includes pictures to help you along the way, which hopefully will help you understand what's going on and what you need to do.

http://www.berecursive.com/2008/c/rotating-a-sprite-towards-an-object-in-xna

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜