原谅我的无知,但我很难记住我在代码中访问的内容。我在我的代码中究竟访问了什么?
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到它?
好吧,有道理。如果我做了'playerVelocity.x = CGPointZero;' 那么会只将X设置为零,但是将Y留在任何位置..? – 2012-02-03 06:34:11
不,'playerVelocity.x'只是CGPoint的x分量,它是一个CGFloat值(即浮点数)。如果你想把x分量设置为0,你可以'playerVelocity.x = 0.0' – UIAdam 2012-02-03 06:35:58
非常感谢。这就是我一直在寻找的。 – 2012-02-03 06:41:17