Page 1 of 1

[Solved]Can't get my images working.

Posted: Sun May 17, 2015 5:12 pm
by BGBgus
Hi there, Lovers!

I've been making my first steps in game developing and, specially, in Löve2D. I have downloaded the offline documentation and I've been looking on the Wiki for some tutorials. Really beginning here, just with my doing some Callback's tests.

In the tutorial, I've seen how to load and draw an image, but it's not working at all. Don't know if its some GNU/Linux problem (my OS, wouldn't be the first problem I've seen, the price of freedom) or, more probably, I'm doing something wrong.

I attach you the important parts of the code here.

Code: Select all

function love.load()
	image = love.graphics.newImage("img/face.png")
	imgx = 450
	imgy = 100
end

function love.draw()
   love.graphics.draw(image, imgx, imgy)
end
And the rest of it, I've uploaded it to Google Drive. Should be some git repository or something like that, but it's just a main.lua file, you know?
https://drive.google.com/file/d/0B2qq5b ... sp=sharing

Also, here you got a screenshot of my test behavior, in case you can't repeat the problem.
https://drive.google.com/file/d/0B2qq5b ... sp=sharing

By the way, what's all this "obey"-avatar thing you have in this forum? Just curiosity xD

Edited:
I've been keeping doing my tests, and it works with this code (on the post) but no with the full code on my main.lua, so it's obvious I'm doing something wrong.

Re: Can't get my images working.

Posted: Sun May 17, 2015 5:39 pm
by BOT-Brad
In your code in the main.lua on line 6, you have

Code: Select all

love.graphics.setColor(0,0,0)
This will make everything you draw black.

Making your draw function like this will fix your issue;

Code: Select all

function love.draw()
   love.graphics.setColor(255, 255, 255, 255)
   love.graphics.draw(image, imgx, imgy)
   love.graphics.print("Click and drag the cake around or use the arrow keys", 10, 10)
end

Re: Can't get my images working.

Posted: Sun May 17, 2015 5:43 pm
by BGBgus
Thank you, BOT-Brad, that does solve my black-image issue!

But, then, my word become white to, you know any way of changing their colour to black without changing image's behaviour?

Re: Can't get my images working.

Posted: Sun May 17, 2015 5:46 pm
by s-ol
BGBgus wrote:Thank you, BOT-Brad, that does solve my black-image issue!

But, then, my word become white to, you know any way of changing their colour to black without changing image's behaviour?
You just need to change the color back right before drawing the image.

Re: Can't get my images working.

Posted: Sun May 17, 2015 5:47 pm
by BOT-Brad
BGBgus wrote:Thank you, BOT-Brad, that does solve my black-image issue!

But, then, my word become white to, you know any way of changing their colour to black without changing image's behaviour?
Sure

Code: Select all

function love.draw()
   love.graphics.setColor(255, 255, 255, 255)
   love.graphics.draw(image, imgx, imgy)
   love.graphics.setColor(0, 0, 0, 255)
   love.graphics.print("Click and drag the cake around or use the arrow keys", 10, 10)
end
love.graphics.setColor will make any draw functions (print, draw, rectangle, circle, polygon, etc.) that particular color after it has been set. It is absolutely fine to call the function many, many times in a single frame. :)

Re: Can't get my images working.

Posted: Sun May 17, 2015 5:55 pm
by BGBgus
Thank you, guys, this is pretty much it! I'll keep with my studies :awesome: