confused about print() statements
Posted: Thu Jan 18, 2018 3:58 pm
I'm VERY confused.
In main.lua I have function love.draw(), the first line of which is:
print("Game has started.").
This is followed by a love.graphics.draw statement that draws the background image.
After this there is a series of if statements to call a draw function depending on the game state, one of which is “splash”.
In the splash.lua file there is a draw function which draws the screen for this scene. It essentially works fine. When the game state is splash, the game draws everything in the splash draw function. The problem is that the above mentioned print statement (print("Game has started.")) doesn’t print in the console as expected, since it is in the love.draw() function BEFORE any of the if statments. Additionally, at the beginning of the main.lua file, immediately after defining gameState = "splash", there is a print statement, print("gameState = " , gameState), which also DOESN’T print in the console.
The funny thing is, when these print statement weren’t printing, in my attempts to figure out why, I added a print statement, print("in stateSplash.draw()"), to the stateSplash.draw() function in the splash.lua file. With this statement in place ALL of the print statements printed: this statement, the one at the beginning of main and the one in the if block in love.draw().
I commented out the print statment in stateSplash.draw() and again, NONE of the print statements printed. I don’t understand this behavior.
In main.lua I have function love.draw(), the first line of which is:
print("Game has started.").
This is followed by a love.graphics.draw statement that draws the background image.
After this there is a series of if statements to call a draw function depending on the game state, one of which is “splash”.
In the splash.lua file there is a draw function which draws the screen for this scene. It essentially works fine. When the game state is splash, the game draws everything in the splash draw function. The problem is that the above mentioned print statement (print("Game has started.")) doesn’t print in the console as expected, since it is in the love.draw() function BEFORE any of the if statments. Additionally, at the beginning of the main.lua file, immediately after defining gameState = "splash", there is a print statement, print("gameState = " , gameState), which also DOESN’T print in the console.
The funny thing is, when these print statement weren’t printing, in my attempts to figure out why, I added a print statement, print("in stateSplash.draw()"), to the stateSplash.draw() function in the splash.lua file. With this statement in place ALL of the print statements printed: this statement, the one at the beginning of main and the one in the if block in love.draw().
I commented out the print statment in stateSplash.draw() and again, NONE of the print statements printed. I don’t understand this behavior.