Hello again,
I’m working on implementing a HUD for my game and can’t get past one annoying error.
Python module can't be imported - object 'DynamCamera', controller 'Python2':
Traceback (most recent call last):
File "F:\Documents\school\3d_modelling\Private\BGE\PHYS\12060.blend~\HUD.py",
line 11, in <module>
TypeError: __init__() missing 1 required positional argument: 'textlib'
I’ve looked this up all over the place with no success.
here is my code:
import sys
# So we can find the bgui module
sys.path.append('../..')
import bgui
import bge
import time
from bge import logic as g
bsys = bgui.System()
class MySys(bgui.System):
"""
A subclass to handle our game specific gui
"""
def __init__(self):
# Initialize the system
bsys.__init__(self)
# Create the button
self.fps = bgui.Label(self, 'fps', text='', pos=[0.03, 0.95], font="FanHeitiStd.otf", pt_size=24)
self.progresstxt = bgui.Label(self, 'progresstxt', text='Health', pos=[0.8, 0.96], font="FanHeitiStd.otf", pt_size=26)
self.progress = bgui.Label(self, 'progress', text='', pos=[0.8, 0.9], font="FanHeitiStd.otf", pt_size=54)
self.progressbar = bgui.ProgressBar(self, 'progressbar', percent=100.0,size=[0.1,0.015], pos=[0.8,0.87])
#items = ["One", "Two", 4, 4.6]
#self.lb = bgui.ListBox(self, "lb", items=items, padding=0.02, size=[0.9, 0.9], pos=[0.05, 0.05])
#self.racer = bgui.Label(self, 'racer', text='racer', pos=[0.5, 0.5], font="FanHeitiStd.otf", pt_size=20)
def main(self):
"""A high-level method to be run every frame"""
# Now setup the scene callback so we can draw
bge.logic.getCurrentScene().post_draw = [self.render]
def main(cont):
own = cont.owner
scene = g.getCurrentScene()
camera = scene.active_camera
fps = g.getAverageFrameRate()
own["fps"] = fps
own["framerate"] = str("%s%s"%(round(1)," FPS"))
own["HP"] = str("%s%s"%(round(1)," %"))
if 'sys' not in own:
# Create our system and show the mouse
own['sys'] = MySys()
else:
own['sys'].main()
own['sys'].fps.text = own['framerate']
own['sys'].progress.text = own['HP']
own['sys'].progressbar.percent = own['caru']/100