[Solved]Can't get my images working.

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
BGBgus
Prole
Posts: 10
Joined: Wed Apr 29, 2015 7:47 am
Location: Terrassa, Barcelona, Spain

[Solved]Can't get my images working.

Post 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.
Last edited by BGBgus on Sun May 17, 2015 5:55 pm, edited 1 time in total.
User avatar
BOT-Brad
Citizen
Posts: 87
Joined: Tue Dec 02, 2014 2:17 pm
Location: England

Re: Can't get my images working.

Post 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
Follow me on GitHub! | Send me a friend request on PSN!
BGBgus
Prole
Posts: 10
Joined: Wed Apr 29, 2015 7:47 am
Location: Terrassa, Barcelona, Spain

Re: Can't get my images working.

Post 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?
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: Can't get my images working.

Post 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.

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
User avatar
BOT-Brad
Citizen
Posts: 87
Joined: Tue Dec 02, 2014 2:17 pm
Location: England

Re: Can't get my images working.

Post 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. :)
Follow me on GitHub! | Send me a friend request on PSN!
BGBgus
Prole
Posts: 10
Joined: Wed Apr 29, 2015 7:47 am
Location: Terrassa, Barcelona, Spain

Re: Can't get my images working.

Post by BGBgus »

Thank you, guys, this is pretty much it! I'll keep with my studies :awesome:
Post Reply

Who is online

Users browsing this forum: pgimeno and 9 guests