J
James Sarjeant
Hi all,
I have a program which generates a set of images based on some data and
displays them on the screen in various places based on a counter
representing the steps so step 1, step 2 etc. I want the user to be able to
scroll through the steps 1 at a time by clicking a button or if they press
play, I want the steps to scroll automatically but with a delay in the
middle.
I have created a scrollForward() method which updates everything just once
for the next step in the sequence and for the playAnim() method I call
scrollForward(), then wait for a delay (using the system time and a speed
variable) then scrollForward() again until the end is reached. The only
problem is that the scrollForward() method works fine but the playAnim()
method simply calculates all the steps but only shows the final state of the
images with no intermediate steps. Does anyone have any ideas of how to get
this to work? Due to the nature of the program I cant use a thread, hence
the system time wait method but it just doesnt put the pictures on the
screen. The two methods are below if they provide any insights.
public void scrollForward()
{
if((programCount + 1) < numInstructions)
{
if(compiled)
{
updatePC(true);
updateImages();
}
else
{
showError("Your machine code must be compiled before you can
scroll.", "Compile error");
}
}
else
{
showError("No more instructions to show.", "Input error");
}
}
public void playAnim()
{
while (running)
{
scrollForward();
long current = System.currentTimeMillis();
long start = current + (speed * 250);
while(System.currentTimeMillis() <= start)
{
// wait and do nothing
}
if(programCount < numInstructions-1)
{
running = false;
}
}
System.out.println("end Anim");
}
The scrollForward works fine but as soon as it is run in a loop it works but
doesnt show the images. Any ideas are welcome.
Thanks in advance and sorry this post is quite long.
Cheers
James
I have a program which generates a set of images based on some data and
displays them on the screen in various places based on a counter
representing the steps so step 1, step 2 etc. I want the user to be able to
scroll through the steps 1 at a time by clicking a button or if they press
play, I want the steps to scroll automatically but with a delay in the
middle.
I have created a scrollForward() method which updates everything just once
for the next step in the sequence and for the playAnim() method I call
scrollForward(), then wait for a delay (using the system time and a speed
variable) then scrollForward() again until the end is reached. The only
problem is that the scrollForward() method works fine but the playAnim()
method simply calculates all the steps but only shows the final state of the
images with no intermediate steps. Does anyone have any ideas of how to get
this to work? Due to the nature of the program I cant use a thread, hence
the system time wait method but it just doesnt put the pictures on the
screen. The two methods are below if they provide any insights.
public void scrollForward()
{
if((programCount + 1) < numInstructions)
{
if(compiled)
{
updatePC(true);
updateImages();
}
else
{
showError("Your machine code must be compiled before you can
scroll.", "Compile error");
}
}
else
{
showError("No more instructions to show.", "Input error");
}
}
public void playAnim()
{
while (running)
{
scrollForward();
long current = System.currentTimeMillis();
long start = current + (speed * 250);
while(System.currentTimeMillis() <= start)
{
// wait and do nothing
}
if(programCount < numInstructions-1)
{
running = false;
}
}
System.out.println("end Anim");
}
The scrollForward works fine but as soon as it is run in a loop it works but
doesnt show the images. Any ideas are welcome.
Thanks in advance and sorry this post is quite long.
Cheers
James