Making an aspect disappear

Viewed 34

I am making a pong game in python, and Im trying to make text appear for a few seconds and then disapear, can someone help me with this:

Instructions.speed(0)
Instructions.color("green")
Instructions.penup()
Instructions.hideturtle()
Instructions.goto(0, -260)
Instructions.color("red")
Instructions.write("W,A and arrow keys to move", align="center", font=("Courier", 36, "normal"))

What else do I need to add?

1 Answers

After writing the text, we can initiate a screen ontimer event to invoke the turtle's clear() method to erase the text. For example:

from turtle import Screen, Turtle

screen = Screen()

turtle = Turtle()
turtle.hideturtle()
turtle.color('red')
turtle.penup()
turtle.sety(-260)

turtle.write("W,A and arrow keys to move", align='center', font=('Courier', 36, 'normal'))
screen.ontimer(turtle.clear, 2000)  # milliseconds in the future

screen.mainloop()
Related