我到底在代码中访问什么?
请原谅我的无知,但我很难记住我在代码中访问的内容。
if (pos.x < leftBorderLimit)
{
pos.x = leftBorderLimit;
playerVelocity = CGPointZero;
}
else if (pos.x > rightBorderLimit)
{
pos.x = rightBorderLimit;
playerVelocity = CGPointZero;
}
这是我所知道的。我知道当我执行 'playerVariable.x'
(这是一个 CGPoint 变量)时,我正在访问此变量 X 轴,我可以用它做任何我想做的事情..但是当我执行此操作时到底发生了什么我只是执行 'playerVelocity = ..... '
,当我将 CGPointZero 分配给它时会发生什么?
Forgive my ignorance but I have a hard time remembering what I'm accessing in my code.
if (pos.x < leftBorderLimit)
{
pos.x = leftBorderLimit;
playerVelocity = CGPointZero;
}
else if (pos.x > rightBorderLimit)
{
pos.x = rightBorderLimit;
playerVelocity = CGPointZero;
}
Here's what I know. I know that when I do 'playerVariable.x'
(which is a CGPoint variable) I'm accessing this variables X axis and I can do whatever I want with it.. but what exactly is happening when I just do 'playerVelocity = ..... '
and what happens when I assign CGPointZero to it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
playerVelocity
必须是 CGPoint,以便您可以表示速度的 x 和 y 分量。将CGPointZero
分配给playerVelocity
会将 x 和 y 分量设置为 0。playerVelocity
must be a CGPoint so that you can represent the x- and y-component of the velocity. AssigningCGPointZero
toplayerVelocity
will set both the x and y components to 0.playerVelocity = CGPointZero;
表示playerVelocity = CGPointMake(0,0);
。playerVelocity = CGPointZero;
meansplayerVelocity = CGPointMake(0,0);
.