Skip to content
← Back to Community
How to use turtle.onscreenclick?
Profile icon
AlexanderTarn

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 [earned 5 cycles]
View Answer
Voters
Profile icon
KLCswetha
Profile icon
AlexanderBloom1
Profile icon
mwilki7
Profile icon
AlexanderTarn
Comments
hotnewtop
Profile icon
mwilki7

Here is an example repl:
https://repl.it/@mwilki7/turtle-testing

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.

Profile icon
AlexanderTarn

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

Profile icon
mwilki7

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

Profile icon
AlexanderTarn

@mwilki7 no this is on my program.

Profile icon
mwilki7

@AlexanderTarn
try turtle.Screen()

Profile icon
AlexanderTarn

@mwilki7 THANK YOU