Object animation using a picture?
I need to animate a picture such that it moves forward a bit and backward a bit. Kind of like a moving room. I'm having trouble; here's what I've got:
import viz
tex1 = viz.add('picture.jpg')
quad = viz.add(viz.TEXQUAD)
quad.translate(0,1,12)
quad.scale(12.8, 10.24)
quad.texture(tex1)
moveForward = vizact.move(0,0,2,5)
moveBackward = vizact.move(0,0,-2,5)
#tex1.add(moveForward)
#tex1.add(moveBackward)
MovingRoom = vizact.sequence(moveForward,moveBackward,4)
def onkeydown(key):
if key == ' ':
tex1.add(MovingRoom)
viz.callback(viz.KEYDOWN_EVENT,onkeydown)
But when I run the script I get this error message:
Traceback (most recent call last):
File "Moving Room 3.py", line 25, in onkeydown
tex1.add(MovingRoom)
AttributeError: VizTexture instance has no attribute 'add'
Which, I guess, makes sense to me. But I wondering if there is a way around this. Like, how can I make it such that the picture moves forward X distance for Y duration and then backward X distance for Y duration...etc (i.e. put that in a loop/timer). Namely, I'd like the picture to keep moving forward and backward the entire time the script is running.
Thanks for the help.
|