Been away from panda for a bit and just came back. love the new site’s look and organization.
I downloaded 1.7 and was glad to see the code I’d written in 1.6 was still running fine. Reading through the manual, I noticed the newer way (to me anyway) of structurung the program. Namely:
from direct.showbase.ShowBase import ShowBase
class MyApp(ShowBase):
def __init__(self):
ShowBase.__init__(self)
app = MyApp()
app.run()
so i modified my code a bit to do it this way. I had code like this:
import direct.directbase.DirectStart
from direct.showbase import DirectObject
class MyGame(DirectObject.DirectObject):
def __init__(self):
g = MyGame()
run()
Like I said my code worked fine, but after I changed it - it bombs out with exit code 1.
Can’t find a reason why. I even created a new py file with just the 6 lines in my first code example (right from the manual) and panda won’t start up.
Hmm, is it possible you still have a reference to DirectStart somewhere, even after the new change? You must not import DirectStart if you are creating your own ShowBase instance.
sorry for being slow on this but how do i get loader into my code?
I’d like to use loader without using this line:
import direct.directbase.DirectStart
Im trying
from direct.showbase.Loader import Loader
and
from direct.showbase.Loader import *
but no luck.
Yeah, this is exactly why I revamped the A Panda Hello World tutorial to use ShowBase instead of DirectStart. The old way got people dependent on everything being up and ready to go after a single import line.
‘loader’ is a member of ShowBase, though it is also stashed into builtins to make Python treat it as a built-in function (along with the likes of hasattr() and isinstance()), which means the user can call it anywhere in the entire program without importing a thing. This is why you can run even self.GAME_FONT = loader.loadFont() without it crashing. Since your program’s main class is inheriting from ShowBase, you could also write self.GAME_FONT = self.loader.loadFont(). The point being that it’s ShowBase.loader that you’re using.