[[thread]]
 

MyScene.java

    private void click ()
    {
        if (! stopped)
           t.suspend ();
        else 
            t.resume();
 
        stopped = ! stopped;
    }
 
    MyThread t;
    boolean stopped;
 
    public void run() {
 
        MyThread t = new MyThread (this);
        t.start ();
 
        this.bunny2.addMouseButtonListener(new MouseButtonListener() {
            public void mouseButtonClicked(final MouseButtonEvent e) {
                MyScene.this.bunny2.say("hello");
                click ();
            }
        });
 
    }

MyThread.java

 
import org.alice.apis.moveandturn.*;
 
public class MyThread extends Thread
{
    private MyScene scene;
 
    public MyThread (MyScene s)
    {
        scene = s;
    }
 
    public void run ()
    {
        while (true) 
        {
            // import org.alice.apis.moveandturn.*;
            scene.bunny2.move (MoveDirection.FORWARD, 2.0);
            scene.bunny2.turn (TurnDirection.RIGHT, 0.333);
        }
 
    }
 
}
 
thread.txt · Last modified: 2014/11/27 18:06 by 147.32.8.115
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki