Solarus-Games English Forum

Solarus => Bugs & Feature requests => Topic started by: MetalZelda on January 05, 2017, 12:11:00 AM

Title: surface:fade_in/out issue ?
Post by: MetalZelda on January 05, 2017, 12:11:00 AM
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 ?
Title: Re: surface:fade_in/out issue ?
Post by: Zefk on January 05, 2017, 12:55:43 AM
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.
Title: Re: surface:fade_in/out issue ?
Post by: MetalZelda on January 07, 2017, 06:14:50 PM
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
Title: Re: surface:fade_in/out issue ?
Post by: Diarandor on January 07, 2017, 07:54:59 PM
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.
Title: Re: surface:fade_in/out issue ?
Post by: Christopho on January 07, 2017, 09:13:43 PM
Looks like a bug.
Title: Re: surface:fade_in/out issue ?
Post by: Diarandor on January 07, 2017, 09:38:37 PM
@MetalZelda: could you open an issue in github for this? (Before this subject is forgotten...) Thanks!