Image transparency and endsound

Hi for all

Thanks for the support you guys has gave me. I have another doubts.
In my game I want to insert a image that represents my game over screen. I want this image beginning totally transparent and gradatively will being opaque. So, how can I do this with the OnscreenImage? Is there a way do to this? better, is there other ways to do this? Do I need to put a method in a taskMgr? I have any idea.
The other question is how can I put a sound whe the image be totally opaque?
Fellows, sorry for the big question, I have no idea how can I do any of these things.

Thanks for the support

hm. guess easyest way would be to set up an lerp-interval which changes your gameovernode.SetColor(1,1,1,0) to (1,1,1,1 )
of course you could also set up a task and do this manually :slight_smile: both should work.

…that would be alphaScale.

nodepath.colorScaleInterval(duration, colorScale, startColorScale=None, other=None, blendType=‘noBlend’, bakeInStart=1, name=None)

ynjh_jo, that won’t work. He wants to scale alpha values, not colors to black.

I use this for fadeing in my object named self.__widgetContainer:

if(self.__widgetContainer.isHidden()):
  Sequence(Func(self.__widgetContainer.setAlphaScale,0.0),Func(self.__widgetContainer.show),LerpFunctionInterval(self.__widgetContainer.setAlphaScale,toData=1.0,fromData=0.0,duration=1.0)).start()

And this for the fade-out:

if(not self.__widgetContainer.isHidden()):
  Sequence(LerpFunctionInterval(self.__widgetContainer.setAlphaScale,toData=0.0,fromData=1.0,duration=1.0),Func(self.__widgetContainer.hide),Func(self.__widgetContainer.setAlphaScale,1.0)).start()

OMG, pro, you’re humiliating yourself again…
wonder why you never use it.

from pandac.PandaModules import Vec4
import direct.directbase.DirectStart
from direct.interval.IntervalGlobal import *

s=loader.loadModel('misc/lilsmiley')
s.reparentTo(aspect2d)
fadeIn=s.colorScaleInterval( 3,Vec4(1,1,1,1),Vec4(1,1,1,0) )
fadeOut=s.colorScaleInterval( 3,Vec4(1,1,1,0) )
Sequence( fadeIn,Wait(.5),fadeOut ).loop()
run()

this is what you’re looking for :

from pandac.PandaModules import Vec4
import direct.directbase.DirectStart
from direct.gui.DirectGui import OnscreenImage
from direct.interval.IntervalGlobal import *

s=OnscreenImage('hyundai-logo.png')
s.reparentTo(aspect2d)
s.setTransparency(1)
fadeIn=s.colorScaleInterval( 3,Vec4(1,1,1,1),Vec4(1,1,1,0) )
fadeOut=s.colorScaleInterval( 3,Vec4(1,1,1,0) )

sound = loader.loadSfx('/h/cut/mustang.mp3')

Sequence( fadeIn,
          Func(sound.play), 
          Wait(sound.length()), # wait until sound finishes
          fadeOut
        ).start()
run()

another one :
discourse.panda3d.org/viewtopic.php?t=3387

Hard ? No, it wasn’t hard at all. Perhaps we should play hard sometimes. :laughing:
Faster ? guess again.

I only able to see this :
= LerpFunctionInterval inherits from Interval, the step does some Python work
= LerpNodePathInterval inherits from CLerpNodePathInterval, the step is done entirely in C
That doesn’t matter much, but I found an interesting thing. Both of them change RenderAttrib of the node, right ?
The diff is :
seems that CLerpNodePathInterval change the attrib only for nodes being sent to gra’card, while FunctionInterval is done for all nodes (who knows if the func is changing RenderAttrib ?).
See the result of the full-culled race :

from pandac.PandaModules import Vec4
import direct.directbase.DirectStart
from direct.interval.IntervalGlobal import *

for i in range(2000):
    s=loader.loadModel('misc/lilsmiley')
    s.reparentTo(aspect2d)
    s.setPos(render2d,10,0,10)

#     fadeIn=s.colorScaleInterval( 3,Vec4(1,1,1,1),Vec4(1,1,1,0) )
#     fadeOut=s.colorScaleInterval( 3,Vec4(1,1,1,0) )
    # 2000 : 20 fps

    fadeIn=LerpFunctionInterval(s.setAlphaScale,3.0,0.0,1.0)
    fadeOut=LerpFunctionInterval(s.setAlphaScale,3.0,1.0,0.0)
    # 2000 : 8 fps

    Sequence( fadeIn,Wait(.5),fadeOut ).loop()
run()

Thanks guys, again you’ve solved my problem.
Thanks for all