问题
I am using python 3.6 and turtle module. I have two turtles in another coordinates. how do i set the angle of turtle_1 to the direction of turtle_2?
回答1:
turtle_1.setheading(turtle_1.towards(turtle_2))
This is typically used if you want turtle_1
to chase turtle_2
. The argument to towards()
is flexible. Besides another turtle, it can also be separate X and Y arguments, or a tuple coordinate pair. If you simply want turtle_1
to point in the same direction as turtle_2
:
turtle_1.setheading(turtle_2.heading())
来源:https://stackoverflow.com/questions/53893541/python-turtle-set-direction-of-a-turtle-to-another-turtle