对python还是新手,所以这对我来说很奇怪......
def getNormalizedStart(self):
# center is Point: {X = 300, Y = 128}
center = self.getTargetCenterFromStart()
# effectiveStart is Point: {X=300.0,Y=472}
effectiveStart = self.getFirstActiveTouchEventLocations()[0]["Point"]\
if self.isTouchTrial() else self.getFirstMouseEventLocation()
radians = float(MathUtils.angle(effectiveStart, center, True))
# Point: {X=-44.0,Y=128.0}
newStart = MathUtils.rotatePoint(effectiveStart, center, -radians)
# newStart.X is float: -44
# center.X is int: 300
newStart.X -= center.X # the result is -344. Good!
# newStart.Y is float: 128.0
# center.Y is int: 128
newStart.Y -= center.Y # the result is -5.68434188608e-14. Wut?
return newStart
但它适用于控制台:
>>> x = 128.0
>>> y = 128
>>> x -= y
>>> x
0.0
我是疯了还是我错过了一些明显的东西?