Page 1 of 1

Problem. I can t see two images at same time

Posted: Mon May 04, 2009 12:08 pm
by Cruiser23rus
Hello. My english is not so well, but i try to describe my problem. Today i try Love engine and i have some trouble with displaing images. I need 3 "layers" with image on each of it's. 1 image on background, second image some closer, and third image most closer then other two. I wright Lua-script, but it's no work. I see only one image (second), which i draw more last then first image . I think i do mistake somewhere. Please, help me. I read documentation, but i can't find information about this case (and there's no documentation on russian language, i'm from Russia). Lua - new program language for me (first day). I hope you understand what i whant to say about my problem.
Thank you. I will waiting for your answers.

There i wright my Lua-code:

Code: Select all

function load() 
    image = love.graphics.newImage("images/back.png")
    image2 = love.graphics.newImage("images/kolob.png")
end 
 
function draw() 
    love.graphics.draw(image, 400, 300)
end   
 
function draw()     
  love.graphics.draw(image2, 700, 500)
end 


Re: Problem. I can t see two images at same time

Posted: Mon May 04, 2009 12:20 pm
by bartbes
The problem is you don't draw the background image, only the front one, because your second draw function overwrites the first one, do it like this:

Code: Select all

function load()
    image = love.graphics.newImage("images/back.png")
    image2 = love.graphics.newImage("images/kolob.png")
end

function draw() 
    love.graphics.draw(image, 400, 300)
    love.graphics.draw(image2, 700, 500)
end 

Re: Problem. I can t see two images at same time

Posted: Mon May 04, 2009 1:00 pm
by Cruiser23rus
Bartbes, thank you very mach!!! You so help me. It' s work!!!
And if i want to do third image, i can do by your example. Thank you.

And one more question. My png images have alpha zone (i save them with alpha). But in the project they displayed without alpha. I must change any parametrs for alpha png?
I read about "set color" alpha, but nothing about png alpha. Do you know something about it?

Re: Problem. I can t see two images at same time

Posted: Mon May 04, 2009 1:10 pm
by bartbes
If the alpha channel is really in the image LÖVE should automatically show them correctly, make sure alpha didn't get changed to white when saving.

Re: Problem. I can t see two images at same time

Posted: Mon May 04, 2009 1:59 pm
by Cruiser23rus
ok. Thank you. I ll chek it. Good day to you.

Re: Problem. I can t see two images at same time

Posted: Mon May 04, 2009 4:24 pm
by Cruiser23rus
Bartbes, if you still heare. You know, it s png files with alfa. I cheked it. I try to attach thoose files heare. Look at them, please.
What can you advise me? May be some setings in Love?

Re: Problem. I can t see two images at same time

Posted: Mon May 04, 2009 4:35 pm
by Robin
Are you sure they have alpha? It doesn't seem that way to me.
EDIT: I gave kolob.png a transparent background. This is the result:
kolob2.png
kolob2.png (558 Bytes) Viewed 8162 times
Does this give you the right result?

Re: Problem. I can t see two images at same time

Posted: Mon May 04, 2009 4:50 pm
by Cruiser23rus
Robin, i don't know what cause of my mistake, but you are right. Thank you.. You know, my windows explorer show me alpha. White color is absent in explorer at this pictures. Hm.. And how did you do this? I must remake my other pictures..

I try to do game-tale about "kolobok" for my child - its old russian tale fore children. =))

Re: Problem. I can t see two images at same time

Posted: Mon May 04, 2009 5:37 pm
by Robin
I used IrfanView. Save As .png and click on the color you want transparent. Although I use other tools that can do that also, but IrfanView is the easiest for quick fixes.

Re: Problem. I can t see two images at same time

Posted: Tue May 05, 2009 9:02 am
by Cruiser23rus
Thank you, Robin. I dounload Ifran now. On my second PC installed Photoshop, but this computer often use my wooman. I think i install on my computer Photoshop too. This pictures i draw in standart Paint of Windows. =) And picturues not cool.
Ok. Thank you. I show you game when it will be done.