Can you make a VAR public to two files


#1

Is there a way I can declare a variable such as var public score:Int = 0 in such a way that a 2nd file in my project can read an manipulate it without sending that variable to the 2nd file in a function?


#2

You can declare it static. public static var score:Int = 0; If you declare in class G.hx as example, you can access it with G.score


#3

That is exactly what I’ve been missing! Thank you so much.

(Will this same concept work with functions as well?)


#4

Absolutely.


#5

Great, thanks for your time. You both were a big help.