Hi everyone,
I’m realy new to Panda3d and to Python. I’m trying to make a animation at the beginning of my game saying “blablabla entertainment presents”.
I want the text to be black(invisible on the black background) and slowly become white. Also, I want the text to become bigger or smaller. And also a starting point and a ending point.
I know it’s a lot of things at the same time so I started with the color change.
Here is my code, I don’t know if I use the good way to do this kind of things but anyway it doesn’t work. (See error below code)
Code:
import direct.directbase.DirectStart
from direct.task import Task
from pandac.PandaModules import *
from direct.gui.DirectGui import *
import sys
class World:
def __init__(self):
text = TextNode('company')
text.setText("blablabla Entertainment Presents")
textNodePath = aspect2d.attachNewNode(text)
textNodePath.setScale(0.1)
#text color
text.setTextColor(1, 1, 1, 1)
#text shadow
text.setShadow(0.1, 0.1)
text.setShadowColor(1, 0, 0, 1)
#text centered
text.setAlign(TextNode.ACenter)
#text position
#???
indice = 0
base.setBackgroundColor(0, 0, 0)
base.disableMouse()
#Task to move the camera
def ChangeColorTask(task):
indice = indice + 0.01
text.setTextColor(1,1,1,1)
if task.time < 2.0:
return Task.cont
print 'Done'
return Task.done
taskMgr.add(ChangeColorTask, "ChangeColorTask")
w = World()
run()
The error is:
File “welcome.py”, line 30, in ChangeColorTask
indice = indice + 0.01
UnboundLocalError: local variable ‘indice’ referenced before assignment
So, maybe the method I use is not the right one! Please help me
Thanks!!
Jaff