Let's load up an Actor
with an animation and start it playing to get a feel for how this works:
Open a blank document in NotePad++ and save it as
Anim_01.py
in theChapter09
folder.We need a few imports to start with. Put these lines at the top of the file:
import direct.directbase.DirectStart from pandac.PandaModules import * from direct.actor.Actor import Actor
We won't need a lot of code for our class'
__init__
method so let's just plow through it here :class World: def __init__(self): base.disableMouse() base.camera.setPos(0, -5, 1) self.setupLight() self.kid = Actor("../Models/Kid.egg", {"Walk" : "../Animations/Walk.egg"}) self.kid.reparentTo(render) self.kid.loop("Walk") self.kid.setH(180)
The next thing we want to do is steal our
setupLight()
method from theTrack
class and paste it into this class:def setupLight(self): primeL = DirectionalLight("prime") primeL.setColor(VBase4(.6,.6,.6,1)) ...