PDA

View Full Version : Timer vs. Keyboard input


Wenamun
01-19-2006, 01:33 PM
Hi.
I want to trigger a series of actions with a single keystroke.
Some of these actions need to use viz.FASTEST_EXPIRATION and viz.FOREVER though, as I am getting input from a mouse and a PPT system.

Here's my code:

viz.go()

PORT_PPT = 4

ball = viz.add('white_ball.wrl')
ball.translate(0,1,8)
ball.alpha(0)

#Now we press "1"
#The ball fades in...
#The ball scales vertically according ...
#to the height of the mouse...
#but it only scales to the initial height...
#it doesn't update in real time.

def ontimer(num):
if viz.iskeydown('1'):
print '"1" key is down'
mousePos = viz.mousepos()
ball.scale(3,mousePos[1])
ball.fade(0,1,4)
elif viz.iskeydown('u'):
print "Undo"
ball.fade(1,0,2)
viz.callback(viz.TIMER_EVENT, ontimer)
viz.starttimer(1,viz.FASTEST_EXPIRATION, viz.FOREVER)


thanks for any help!

-Wenamun

tobin
01-23-2006, 09:04 PM
Can you please phrase what your difficulty is in more precise terms?