WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   reseting actions (https://forum.worldviz.com/showthread.php?t=1920)

nlfrnassimi 03-19-2009 12:34 AM

reseting actions
 
Hi, I have created a test code. In my code there is a ball that waits 5 seconds before it changes color, and according to the color changing there are balls moving around. after the actions have taken place, I want to reset them so that everything starts from the beginning. How can I do that?

Here is my code:

Code:

import viz

viz.go()

import viztask

viz.clearcolor( viz.SKYBLUE )
viz.add( 'tut_ground.wrl' )
ball1 = viz.add( 'white_ball.wrl' )
ball1.setPosition( 0, 3, 4 )

ball2 = viz.add('soccerball.ive')
ball2.setPosition(2,0.3,6)

ball3 = viz.add('soccerball.ive')
ball3.setPosition(-2,0.3,4)




def changeColor():
        while True:
               
               
                color = ball1.color(viz.RED)
                moveball2()

                yield viztask.waitTime( 5 )
               
       
                color = ball1.color(viz.YELLOW)
                moveball3()
       
                yield viztask.waitTime(5)
               

                color = ball1.color(viz.GREEN)
                rotateball3()
                safe()

                yield viztask.waitTime( 5 )
                stopRotate()
               
       
               
viztask.schedule( changeColor() )

def moveball2 ():
        ball2.addAction( vizact.goto ([-1,2,6] ) )
       

       
def moveball3 ():
        ball3.addAction( vizact.goto ([2,2,6] ) )
       
def rotateball3 ():
        ball3.addAction( vizact.spin([0,1,0],90,viz.FOREVER,100))

def stopRotate ():
        ball3.endAction()
       
def safe() :
        safe = viz.addText('SAFE', viz.WORLD)
        safe.setPosition(-1,2,5)
        safe.scale(.5,.5)



All times are GMT -7. The time now is 05:01 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC