black overlay with transparency

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
TheAutomator
Prole
Posts: 12
Joined: Wed Jun 04, 2014 9:25 am

black overlay with transparency

Post by TheAutomator »

hi everyone ;)
I don't know if this is a bug or something but i used my own love.run file
because i wanted to draw something that moves with a tale...

what i did is i made a green bouncing ball that leaves a tale that fades out.
how i did it?

deleted this "love.graphics.clear()" in the loop and changed it with:

love.graphics.setColor( 0, 0, 0, 10)
love.graphics.rectangle("fill", 0, 0, 100, 100) -- screensize is 100x100
love.graphics.setColor( 0, 255, 0, 255 )

it works but the tail does not fully disappear :?
normally it should be overwritten to black after 255 / 10 frames right?

thanks in advance :)
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: black overlay with transparency

Post by Robin »

First, not using love.graphics.clear() is really not the right solution. Try drawing on a canvas instead. (Why? Try hiding your window behind another window for a bit, see what happens.)

So let's see what really happens here:

First frame: 255
Second frame: 255 * 245/255 + 0 * 10/255 = 245
Third frame: 245 * 245/255 = 235
Fourth frame: 235 * 245/255 = 225
Fifth frame: 216
Sixth frame: 207

You see, the change per frame is going down each frame.

I can't really help you without a .love, though.
Help us help you: attach a .love.
User avatar
MadByte
Party member
Posts: 533
Joined: Fri May 03, 2013 6:42 pm
Location: Braunschweig, Germany

Re: black overlay with transparency

Post by MadByte »

Hi there,
your post confuses me & I'm not really sure if you just wanna troll us, but I try to answer this anyway.
I don't know if this is a bug or something but i used my own love.run file
because i wanted to draw something that moves with a tale...
You don't need to change the love.run function for what you are trying to do here. Your solution looks like a preetty ugly hack to get the result.

I don't really know what you exactly want, but here is an example how I would do a "trail" without using löves particle system.
trail.love
Hope that helps.
Next time try to provide a .love with your code. :p
TheAutomator
Prole
Posts: 12
Joined: Wed Jun 04, 2014 9:25 am

Re: black overlay with transparency

Post by TheAutomator »

ok, first of all I never wanted to troll anybody :o:
maybe i'm not so good at typing posts.. my native language is Dutch so sorry for the misunderstanding :)

the thing i want is a smooth tale fading out after every moving object like the image:
Naamloos.png
Naamloos.png (60.95 KiB) Viewed 4955 times
this is the love.run file i use:

Code: Select all

function love.run()

    if love.math then
        love.math.setRandomSeed(os.time())
    end

    if love.event then
        love.event.pump()
    end

    if love.load then love.load(arg) end

    -- We don't want the first frame's dt to include time taken by love.load.
    if love.timer then love.timer.step() end

    local dt = 0

    -- Main loop time.
    while true do
        -- Process events.
        if love.event then
            love.event.pump()
            for e,a,b,c,d in love.event.poll() do
                if e == "quit" then
                    if not love.quit or not love.quit() then
                        if love.audio then
                            love.audio.stop()
                        end
                        return
                    end
                end
                love.handlers[e](a,b,c,d)
            end
        end

        -- Update dt, as we'll be passing it to update
        if love.timer then
            love.timer.step()
            dt = love.timer.getDelta()
        end

        -- Call update and draw
        if love.update then love.update(dt) end -- will pass 0 if love.timer is disabled

        if love.window and love.graphics and love.window.isCreated() then
            --love.graphics.clear()
				
				love.graphics.setBlendMode("alpha")
				love.graphics.setColor( 0, 0, 0, 10 )
				love.graphics.rectangle( "fill", 0, 0, window.w, window.h )
				love.graphics.setColor( 255, 255, 255, 255 )

            love.graphics.origin()
            if love.draw then love.draw() end
            love.graphics.present()
        end

        if love.timer then love.timer.sleep(0.001) end
    end

end
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: black overlay with transparency

Post by Robin »

<Dutch>Als we om een .love vragen (of gelijk als je een probleem hebt), maak een .zip van je project en verander .zip in .love. Dan kunnen we je beter helpen. Nu kunnen we niet zoveel. Zonder de rest van je code te kunnen zien, is mijn advies nog steeds om een [wiki]Canvas[/wiki] te gebruiken.</Dutch>
Help us help you: attach a .love.
TheAutomator
Prole
Posts: 12
Joined: Wed Jun 04, 2014 9:25 am

Re: black overlay with transparency

Post by TheAutomator »

Dutch:

Ok, zal ik doen (kijk maar eens naar de .love file dan) en dat van die 'canvas' zal ik ook eens uitdokteren want dat heb ik nog niet gebruikt...
bedankt ;)

ps: ook al zou ik dan "love.run" niet meer hoeven te gebruiken, ik zou toch graag weten waarom die staart dan niet volledig verdwijnt?

English:

Ok, i will do that (have a look at the .love file then) and i will take a look at the 'canvas' solution, haven't used that before...
thanks ;)

ps: even though I would no longer have to use "love.run", I'd still like to know why the tail not disappears completely?
_____________________________________________________________________________________________________________________

(the .love file won't work, but if you extract it to a folder and drag the folder to the love.exe it works again..)
Attachments
test.love
(3.59 KiB) Downloaded 118 times
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: black overlay with transparency

Post by Robin »

A few words on distribution (because that's easy for me :P):
  • try making a .love from the contents of the project directory, not of the directory itself (dus: selecteer alle bestanden van je project en maak daar een zipje van, in plaats van dat je klikt op de map waar die bestanden in zitten)
  • case matters (let op hoofdletters en kleine letters): it's main.lua and conf.lua, not MAIN.lua and CONF.lua. Also, the extension should always be .lua, never .Lua or anything like that. Windows doesn't care, but other operating systems do, and even on Windows you need to do it right to make .loves work.
As to your real problem, I've tried a few things but didn't really find a solution. I do have this for you: it now uses a canvas instead of changing love.run (which means you can move other windows on top of it and it won't go away) and I've made the background darkgreen, so you don't see any green stripes any more.
Attachments
greenball.love
(2.5 KiB) Downloaded 162 times
Help us help you: attach a .love.
TheAutomator
Prole
Posts: 12
Joined: Wed Jun 04, 2014 9:25 am

Re: black overlay with transparency

Post by TheAutomator »

hmmm, strange thing that the tale keeps visible, could it be some kind of wrong color settings or some bug?
so its also visible in the canvas... that bothers me a bit, want a black background :?

thanks for the afford already everyone btw :)
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: black overlay with transparency

Post by Robin »

Hm, maybe you could use a [wiki]Shader[/wiki], but if you do you'll either have to figure it yourself or ask someone else, because they are not my cup of tea.
Help us help you: attach a .love.
TheAutomator
Prole
Posts: 12
Joined: Wed Jun 04, 2014 9:25 am

Re: black overlay with transparency

Post by TheAutomator »

i'm not trying to make a way around the problem, i'd rather solve it :)
but thanks for the suggestion :)
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 10 guests