角度,角度,角度! [英] Angles, angles, angles!

查看:76
本文介绍了角度,角度,角度!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!



我正试图为我的游戏添加角度。但是,当我添加这些角度时,他们只是不工作:



Hello everyone!

I am trying to add angles to my game. However,
when I add these angles, they just don''t work:

if (e.State.X < Cradle.GraphicsManager.PreferredBackBufferWidth / 2)
    this.Player.EntityHeadAngle = (int)Math.Atan2(e.State.X - Cradle.GraphicsManager.PreferredBackBufferWidth / 2, e.State.Y);

e.State.X = Mouse X,Y
Cradle.GraphicsManager.PreferredBackBufferWidth = Width, Height of the form. 



另外,还应该有一个else语句,但我还不知道怎么做这个,所以我不能去下一个。任何想法为什么这不起作用?



编辑:问题是当我向下看它面朝上时,当我向下看时它不做任何事情。

编辑:编辑:我正试图转头,但是当else语句到达时我翻转了纹理。


Also, there should also be an else statement, but I wasn''t sure how to do this one yet, so I couldn''t go to the next one. Any ideas why this doesn''t work?

The problem is when I look down it faces up, and when I look down it doesn''t do anything.
I''m trying to make a head turn, but I flip the Texture when the else statement arrives.

推荐答案

解决方案:



Solution:

Vector2 dPos = new Vector2(e.State.X - Cradle.GraphicsManager.PreferredBackBufferWidth / 2, e.State.Y - Cradle.GraphicsManager.PreferredBackBufferHeight / 2);
this.Player.EntityHeadAngle = (float)Math.Atan2(dPos.Y, dPos.X);


这篇关于角度,角度,角度!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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