![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Apple Horo |
![]() |
Old Version | Published before Godot 3 was released. |
Hello there. I’m trying to do the in-game menu for different settings, and one of them is using the vsync.
It works perfectly in the editor, but when I try to run the builded binary, at least on linux, I get the following errors in the console:
SCRIPT ERROR: _ready: Invalid call. Nonexistent function 'is_vsync_enabled' in base 'Object'.
At: <built-in>:6.
SCRIPT ERROR: save_config: Invalid call. Nonexistent function 'is_vsync_enabled' in base 'Object'.
At: <built-in>:19.
And 'cause of this, the game fails to save the stuff :<
Is this works how it’s intented to work, or did I miss something.
The code for the scripts is:
extends Button
onready var anim = get_parent().get_node( "anim" );
onready var vsync = OS.is_vsync_enabled();
func _ready():
update_text();
func update_text():
if( vsync ):
set_text( "VSync [X]" );
else:
set_text( "VSync [ ]" );
func _on_vsync_pressed():
music.sfx_play( "hit5" );
vsync = !vsync;
OS.set_use_vsync( vsync );
update_text();
func _on_vsync_focus_enter():
music.sfx_play( "hit1" );
And:
extends Button
onready var anim = get_parent().get_node( "anim" );
var timeout = 1.0;
func _ready():
pass;
func _fixed_process( delta ):
timeout -= delta;
if( timeout <= 0 ):
get_tree().change_scene( "res://menu/menu.tscn" );
set_fixed_process( false );
func save_config():
var config = ConfigFile.new()
config.set_value( "video", "fullscreen", OS.is_window_fullscreen() );
config.set_value( "video", "vsync", OS.is_vsync_enabled() );
config.set_value( "audio", "sound_volume", AudioServer.get_fx_global_volume_scale() );
config.set_value( "audio", "music_volume", AudioServer.get_stream_global_volume_scale() );
config.save( "user://settings.cfg" )
func _on_back_pressed():
save_config();
music.sfx_play( "hit5" );
anim.play( "end" );
set_fixed_process( true );
release_focus();
func _on_back_focus_enter():
music.sfx_play( "hit1" );
UPD: also, the At: <built-in>:6.
is actually line 4, I just have two empty lines in the beginning of that script, if it has some importance or something