1

我有一个 Pjs 草图,如下所示:

void setup(){
 //setup stuff among all, setup:
 Graph graph = new Graph;
}

 void update(String [] input){
 //loop through the input update the Graph class 

 }

void draw(){    
 graph.display();   
}

class Graph{
 //setup graph

 void update(String word){
 //update graph with info
 }
}

 void display() {
  // draw graph; 
 }
}

在javascript部分我有以下(在某些时候):

processingjs.update(String);

所以发生的事情是我有时不会调用 draw() 循环并且什么也没有出现。但是,如果我把 graph.display(); 进入 update() 函数,图形被一致地绘制,但是我失去了在 draw() 中运行它所带来的某些灵活性。

我想知道这是一种预期的行为,我应该重写,就好像我只是使用更新来绘制一样,或者我应该尝试将更新功能移动到绘制循环中(并从 javascript 中调用它)?

如果我可以提供额外的信息,请告诉我。非常感谢任何输入,

谢谢!

4

1 回答 1

1

实际上解决了这个问题。

What I was doing is passing an array to processingjs.update() and then looping through it and updating my graph from within Processing.

The solution is to loop on Javascript side and send to Processing results one by one..

I think I kind of understand why that is so, but if I am wrong, please correct me.

于 2012-04-07T16:40:12.713 回答