我想通过给它更小的 y 和 x 变化来减慢圆的运动,如下所示:if event.key == pygame.K_DOWN: circleYchange = 0 circleXchange = 0 circleYchange += 0.5 if event.key == pygame.K_RIGHT: circleYchange = 0 circleXchange = 0 circleXchange += 0.5然后将其添加到circleY和circleX中,并绘制圆:circleX += circleXchangecircleY += circleYchangepygame.draw.circle(screen, (0, 0, 0), (circleX, circleY), size)但它给了我这种错误:TypeError: integer argument expected, got float如何减慢运动速度?
1 回答
![?](http://img1.sycdn.imooc.com/545868b60001587202200220-100-100.jpg)
森林海
TA贡献2011条经验 获得超2个赞
的中心参数pygame.draw.circle()
必须是具有 2 个整数组件的元组。您必须将round
坐标转换为整数值:
pygame.draw.circle(screen, (0, 0, 0), (round(circleX), round(circleY)), size)
添加回答
举报
0/150
提交
取消