surface:fade_in/out issue ?

Started by MetalZelda, January 05, 2017, 12:11:00 AM

Previous topic - Next topic
Hello.

When fading a surface by using fade in or fade out, our goal is to have the surface's opacity to 255 or 0, but the opacity, is never at 0 or 255, is this intentionnal ?

January 05, 2017, 12:55:43 AM #1 Last Edit: January 05, 2017, 01:01:04 AM by Zefk
It worked for me in the script below.

Code ( lua) Select

--[[
1.Activate fade with key "a"
2.Fade out with key "o"
3.Fade in with key "i"
--]]

--Pass the game parameter to the script.
local game = ...

--Creating surfaces for the images and loading in the images.
local fade_img = sol.surface.create ("fade.png")

local fade = false

--Solarus key pressing function
function sol.main:on_key_pressed(key)

--Pause the game
game:set_paused(true)

--Activates images on key 'a'
   if key == "a" then
     fade = true
   end

----Activates fade in on key 'i'
   if key == "i" then
     fade_img:fade_in(100)
   end

----Activates fade out on key 'o'
   if key == "o" then
     fade_img:fade_out(100)
   end

end -- end of key press function

--Function for drawing or showing images
function sol.main:on_draw(screen)

--Show the fade image if true
  if fade == true then
    fade_img:draw(screen)
  end

end -- end of draw function



I had some issues at first when the image would not fade out completely, but I thought I was just using surface:fade_in/out wrong.

January 07, 2017, 06:14:50 PM #2 Last Edit: January 07, 2017, 06:16:34 PM by MetalZelda
That's not how it looks on me, it is so random, sometimes it fade completely, sometimes not.

https://www.youtube.com/watch?v=KGXre9FlDKQ

Notice that the movement is the same, so it has the same duration whever it is called.

fading lifetime is set to 5, in and out
movement speed is constantly at 139
other objects (text) are moved along with the graphic's x and y

The text is drawn in a surface, so the fade effect can be played, however, it doesn't have the issue it seems ...

For a menu this is not a problem, but for in-game entities like npc or else, this could be problematic

Maybe it's a bug. Or maybe some built-in code is not updating the transparencies in a smooth/continuous way for performance? (Or maybe both things.) If so, maybe Christopho can confirm it.
"If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you."


@MetalZelda: could you open an issue in github for this? (Before this subject is forgotten...) Thanks!
"If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you."