FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Programs
(Moderators: fry, REAS)
   sequential applets?
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: sequential applets?  (Read 406 times)
katya

Email
sequential applets?
« on: Mar 18th, 2004, 3:21pm »

Hi-
 
I've created several pieces that I'd like to show onscreen in an exhibition.  They would just play on one flat screen with no interactivity.  I'm wondering if there is a way that I can make a loop where they switch out to the next one after a specified time. (or can I only show one piece?)
any ideas?
 
Katya
 
TomC

WWW
Re: sequential applets?
« Reply #1 on: Mar 18th, 2004, 3:33pm »

If they are displayed as a series of webpages, then you could use a tag in the head section to forward to the next one.  Forward the last one to the first one, and hey presto! A loop.
 
Code:

<head>
<title>Page 1</title>
<meta http-equiv="refresh"  
content="300;url=page02.html">
</head>

 
That will forward to page 2, 5 minutes after page 1 is loaded.  If you run it full screen (F11 in Internet Explorer), it should be quite effective.
 
One more thought - I have seen web transition effects used, implemented in javascript I think... does anyone know if these work with applets?
 
TomC

WWW
Re: sequential applets?
« Reply #2 on: Mar 18th, 2004, 3:35pm »

Hmm... talking to myself again.
 
Transition effects are also meta tags, apparently...
http://winfolinx.com/tips/howto/various/trans.htm
 
IE only, I'd bet.
 
amoeba

WWW
Re: sequential applets?
« Reply #3 on: Mar 18th, 2004, 7:01pm »

I've used the "refresh" trick before with success. The only downside is the blanking of the screen that happens when the Java Virtual Machine reloads.
 
An OOP alternative is to create separate classes for your pieces, with all classes must have a method "loop" that does all the updating and drawing for each frame. Then you keep track of how long you want to draw for each system, and call the loop() method of the relevant class from the main Processing loop().
« Last Edit: Mar 18th, 2004, 7:02pm by amoeba »  

marius watz // amoeba
http://processing.unlekker.net/
fabsina

Email
Re: sequential applets?
« Reply #4 on: Apr 9th, 2004, 4:25pm »

Are you sure your OOP version works the way you described it?
 
Switching between several applets on mouseclick is what I would like to do.  
 
I tried it the way you described it:
 
Code:

public class Main extends BApplet {
int counter;
BApplet1 b1;
BApplet2 b2;
 
void setup() {
   counter = 0;
 b1 = new BApplet1();
 b2 = new BApplet2();
 b1.loop();
}
 
void mousePressed() {
 if (counter % 2 == 0) {
  b1.loop();
 }
 else {
  b2.loop();
 }
   counter++;
}
}
 
public class BApplet1 extends BApplet {
 void loop() {
  fill(255, 0, 0);
  point(random(200),random(200));
 }
}
//BApplet2 looks just the same
 

 
but I get a Nullpointer Exception:
java.lang.NullPointerException
 at BApplet.fill(BApplet.java:3071)
 at BApplet1.loop(BApplet1.java:15)
 at MainModul.setup(MainModul.java:23)
 at BApplet.init(BApplet.java:185)
 at sun.applet.AppletPanel.run(Unknown Source)
 at java.lang.Thread.run(Unknown Source)
 
 
I've tried it out in different ways but it seems to me that it's not possible to run two loop methods at the same time.
 
Do you have an idea what would be the best way to navigate from one applet to the other by mouseclick? Shall I better do it using the java.applet api (...although I'd like to at least combine it with Processing)?  
 
Any Idea?
Martina
 
v3ga

WWW Email
Re: sequential applets?
« Reply #5 on: Apr 9th, 2004, 9:29pm »

Hello Martina, here's a little code snippet that would work , as suggested by Amoeba :  
 
Code:

Scene1 scene1;
Scene2 scene2;
int counter = 0;
 
void setup()
{
  size(200, 200);
 
 
  scene1 = new Scene1();
  scene2 = new Scene2();
 
}
 
void loop()
{
  if (counter%2 == 0)
    scene1.loop();
   else
    scene2.loop();
}
 
void mousePressed()  
{  
  counter++;
}  
 
class Scene
{
  Scene()
  {}
  public void loop()
  {}
}
 
class Scene1 extends Scene
{
  public void loop()
  {
    background(255,0,0);
    fill(0,0,0);
    rect(30, 20, 55, 55);    
  }
}
 
class Scene2 extends Scene
{
  public void loop()
  {
    fill(255,0,0);
    background(128,128,128);
    rect(0, 0, 100, 100);  
  }
 
}
 

http://v3ga.net
amoeba

WWW
Re: sequential applets?
« Reply #6 on: Apr 9th, 2004, 9:39pm »

V3ga has it right. There is no need to extend BApplet, since your classes are private classes being declared inside BApplet.
 

marius watz // amoeba
http://processing.unlekker.net/
fabsina

Email
Re: sequential applets?
« Reply #7 on: Apr 10th, 2004, 12:07pm »

Thanks guys! I did it like you suggested, but as I wanted to have physically separated classes (I'm programming in Eclipse), I call the drawing methods from the main loop() and hand over the whole Object, so to use the P5 commands also in the other class.
 
Thanks for the inspiration!
 
Pages: 1 

« Previous topic | Next topic »