Ask coding questions

← Back to all posts
How to use turtle.onscreenclick?
AlexanderTarn (280)

I am creating a game where the player clicks on a turtle screen, the turtle then goes to that point and stamps an impression of itself. Anyone know how to use turtle.onscreenclick?

Answered by mwilki7 (1137) [earned 5 cycles]
View Answer
mwilki7 (1137)

Here is an example repl:

The first parameter of onscreenclick() is the name of a function.
onscreenclick() will call this function later, and pass to it the x,y coordinates of your mouse click. So make sure that the function you give it is defined with x,y parameters.

AlexanderTarn (280)

@mwilki7 It gives error:
"Turtle" has no attribute "Screen"

mwilki7 (1137)

try it or refresh page once more, i was copy pasting some stuff

AlexanderTarn (280)

@mwilki7 no this is on my program.