-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFPSTracker.gd
55 lines (38 loc) · 1.54 KB
/
FPSTracker.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
extends CanvasLayer
@onready var currentFPSLabel = $BoxContainer/CurrentFPS
@onready var lowFPSLabel = $BoxContainer/LowFPS
@onready var trackFPSBtn = $BoxContainer/TrackFPSBtn
var savePath:String = OS.get_user_data_dir() + "/test.res";
var isTracking = false;
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
var lowestFps:int = 5000
func _process(_delta):
if isTracking:
var currentFps:int = (int)(Engine.get_frames_per_second())
if currentFps < lowestFps:
lowestFps = currentFps
lowFPSLabel.text = "Lowest: " + str(lowestFps)
currentFPSLabel.text = "FPS: " + str(currentFps)
func _on_track_fps_button_pressed():
isTracking = !isTracking
lowestFps=100000000
func test(arr:Array):
for i in arr:
print(i)
func save():
var factory:BulletFactory2D = get_parent().get_node("Player").get_node("BulletFactory2D") as BulletFactory2D
var factoryData:SaveDataBulletFactory2D = factory.save(); # should return the factory's data
ResourceSaver.save(factoryData,savePath)
func _on_save_btn_pressed():
save()
func _on_load_btn_pressed():
var factory:BulletFactory2D = get_parent().get_node("Player").get_node("BulletFactory2D") as BulletFactory2D
var factoryData:SaveDataBulletFactory2D = ResourceLoader.load(savePath)
factory.call_deferred("clear_all_bullets")
factory.call_deferred("load", factoryData)
func _on_fire_btn_button_down():
get_parent().get_node('Player').mouseBtnHeld = true
func _on_fire_btn_button_up():
get_parent().get_node('Player').mouseBtnHeld = false