Author Topic: surface:fade_in/out issue ?  (Read 1868 times)

MetalZelda

  • Hero Member
  • *****
  • Posts: 551
    • View Profile
surface:fade_in/out issue ?
« 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 ?

Zefk

  • Hero Member
  • *****
  • Posts: 536
  • Just helping Solarus
    • View Profile
    • Zelzec
Re: surface:fade_in/out issue ?
« Reply #1 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.

MetalZelda

  • Hero Member
  • *****
  • Posts: 551
    • View Profile
Re: surface:fade_in/out issue ?
« Reply #2 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
« Last Edit: January 07, 2017, 06:16:34 pm by MetalZelda »

Diarandor

  • Hero Member
  • *****
  • Posts: 1053
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: surface:fade_in/out issue ?
« Reply #3 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.
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1177
    • View Profile
Re: surface:fade_in/out issue ?
« Reply #4 on: January 07, 2017, 09:13:43 pm »
Looks like a bug.

Diarandor

  • Hero Member
  • *****
  • Posts: 1053
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: surface:fade_in/out issue ?
« Reply #5 on: January 07, 2017, 09:38:37 pm »
@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.”