![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | lincolnpepper |
I have a timer called start_timer
that starts incrementing whenever the boolean started
becomes true. started
turns true when you hit spacebar to start the game. Whenever the timer hits a certain limit the game starts. This is to give time for the sound effect to play, and i also use the timer to determine when to turn the text label on and off, to show a flashing effect (using if start_timer%20 == 0:
). I used print to print start_timer
when i was testing it, obviously, but when i took the print away it went really fast for some reason? If the game is running at 60 fps, then i expect it to take more than a second for the start timer to reach 90 but it goes by in less than half a second really quickly. And i cant test to see what is happening because when i use print the problem goes away! Anyone have any idea what is going on? Here is the code:
extends Node
var started = false
var labelshowing = true
var start_timer = 0
func _process(delta):
if Input.is_key_pressed(KEY_SPACE) and started == false:
$"StartSound".play()
started = true
$"MenuText".hide()
if started == true:
start_timer += 1
if start_timer%20 == 0:
if labelshowing == true:
$"MenuText".hide()
labelshowing = false
elif labelshowing == false:
$"MenuText".show()
labelshowing = true
if start_timer >= 90:
get_tree().change_scene("res://Main.tscn")