MichaelSinsbeck / platformer

A ninja platformer written in LÖVE
7 stars 0 forks source link

Lines disappear during death sequence #61

Closed michalove closed 11 years ago

michalove commented 11 years ago

The lines for sliding down disappear, during death sequence. See for example level "weeee". Do you have any idea, why this happens? The line:draw sets both line width and color.

Germanunkol commented 11 years ago

Uh, yes... all of love's draw calls (except for images and canvases) will not be affected by shaders, i.e. when I access the texture/image in the shader, the pixels where the line is drawn will simply be blanc, so the shader doesn't "know" to draw something there. Same goes for love.graphics.rectangle, circle, polygon etc.

Workaround is to draw the full scene to a canvas first and then fade this to grey (ugly) or draw the lines again over the final image (also ugly) if the shader is active.

michalove commented 11 years ago

Since the line is drawn in black, can we switch off the shader just for drawing the line? We could either do this by adding some codes in line:draw. (That means for each line the shader is deactivated once and then activated) Or we could put all lines into a different table than the 'normal' objects and draw them before the objects (Deactivate shader only once).

Germanunkol commented 11 years ago

Thanks, switching off the shader off just for the line drawing worked nicely. It wasn't even as ugly as I suspected, because there's a function love.graphics.getPixelEffect, which returns the currently active shader.