Page 1 of 2
Fixing An Incorrectly Coded Drawing Function
Posted: Fri Jul 19, 2013 6:49 pm
by Rehnrald
This is my first post, sadly it must be one asking for help.... Anyway, my problem is that clicking the "New Game" button on the menu causes a problem with loading the background. I don't see a problem, as I defined the background correctly (background = love.graphics.newImage("<filename.extension>"), and called it correctly (to my knowledge) with:
function love.draw()
love.graphics.draw(background)
love.graphics.draw(Llama, x, y)
end
end
I would appreciate help, thanks in advance.
Re: Fixing An Incorrectly Coded Drawing Function
Posted: Fri Jul 19, 2013 7:45 pm
by Innocuous
Hello and welcome! I very new myself but I took the liberty to look through your code. There is no problem with your draw function but it appears to break when your on-click event leads to the function TITLE.newGame(button) which is already running. Maybe if you change the on-click, you will fix the issues.
Re: Fixing An Incorrectly Coded Drawing Function
Posted: Fri Jul 19, 2013 9:21 pm
by Rehnrald
I couldn't exactly grasp what you were trying to say, but I moved the TITLE.newGame block to below the block that defines it as a variable. I also changed some variables and such, but doing that made it so the song plays, but the background and player character aren't drawn at all. It just stays at the main menu whilst playing the audio.
Re: Fixing An Incorrectly Coded Drawing Function
Posted: Fri Jul 19, 2013 9:23 pm
by Innocuous
Could you post the current state of the project? Would like to have another look at it for you.
Re: Fixing An Incorrectly Coded Drawing Function
Posted: Fri Jul 19, 2013 9:30 pm
by Rehnrald
Sure, here it is:
Re: Fixing An Incorrectly Coded Drawing Function
Posted: Sat Jul 20, 2013 3:57 am
by Davidobot
I looked at the OP, so I don't know if anything changed but:
Code: Select all
function love.draw()
love.graphics.draw(background, 0, 0)
love.graphics.draw(Llama, x, y)
end
I think that should fix it?
Re: Fixing An Incorrectly Coded Drawing Function
Posted: Sat Jul 20, 2013 8:54 am
by bartbes
Davidobot wrote:
I think that should fix it?
The X and Y coordinates default to 0, so that is equal.
Re: Fixing An Incorrectly Coded Drawing Function
Posted: Sat Jul 20, 2013 9:11 am
by Innocuous
Davidobot wrote:I looked at the OP, so I don't know if anything changed but:
Code: Select all
function love.draw()
love.graphics.draw(background, 0, 0)
love.graphics.draw(Llama, x, y)
end
I think that should fix it?
Well, his Load callback was in another function so the extra 'end' was not the problem.
Re: Fixing An Incorrectly Coded Drawing Function
Posted: Sun Jul 21, 2013 6:24 am
by Rehnrald
I am driving on a large road trip, so my replies have been scarce... But, I tried using the code Davidobot sent (even though it seems redundant) and it caused no difference whatsoever. I still haven't found the source of the problem still, however.
Re: Fixing An Incorrectly Coded Drawing Function
Posted: Sun Jul 21, 2013 8:43 am
by Davidobot
Rehnrald wrote:I am driving on a large road trip, so my replies have been scarce... But, I tried using the code Davidobot sent (even though it seems redundant) and it caused no difference whatsoever. I still haven't found the source of the problem still, however.
My coding style is very different from yours, so I might have not understood your code, but you can't have multiple love.loads, love.updates and love.draw.
Here is the fixed .love:
https://dl.dropboxusercontent.com/u/354 ... Menu2.love