在 C# 中添加到向量2?为何如此?
我正在使用 Flash/AS3 和 Flixel 进行一些试验和错误,以使汽车自行移动到各个路径点。无论如何,我已经找到了 Microsoft 的一些 XNA/C# 代码,并且正在尝试对其进行转换,但我被困在与向量有关的两位上......
location = location + (Direction *
MoveSpeed * elapsedTime);
“位置”是一个 Vector2。
类似地:
tank.Location + (orth * turningRadius)
“.Location”和“orth”也是 Vector2 的。
有人能告诉我这实际上是在做什么吗?
我不明白如何将单个数字与 Vector2 相加或相乘,但也许我遗漏了一些明显的东西!
干杯
克里斯
I'm doing a bit of trial and error with Flash/AS3 and Flixel to make a car move to various waypoints on its own. Anyway I have found some code by Microsoft for XNA/C# and am trying to convert it but am stuck on two bits to do with vectors...
location = location + (Direction *
MoveSpeed * elapsedTime);
"location" is a Vector2.
Similarly:
tank.Location + (orth * turningRadius)
".Location" and "orth" are also both Vector2's.
Can anybody tell me what this is actually doing?
I don't understand how you can add or multiply a single number to a Vector2 but maybe I am missing something obvious!!
Cheers
Chris
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
编译器正在为你做一些好事。实际上,代码的作用是这样的:
快速简单的向量数学介绍:
The compiler is doing some nice things for you. In effect what the code is doing is this:
A quick and simple vector math intro: http://johnnygizmo.blogspot.com/2008/10/xna-sidebar-intro-to-vector-math.html