处理'看起来你正在混合“活动”和“静态”模式“。 [英] Processing 'It looks like you're mixing "active" and "static" modes.'

查看:476
本文介绍了处理'看起来你正在混合“活动”和“静态”模式“。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行它时,处理仍然给我这个错误,即使它只是一个打印命令。当我删除注释块它工作正常。这里是代码:

Processing keeps giving me this error when I run it even though it is just a print command. When I delete the comment block it works fine. Here's the code:

/*
    float[] cortToPolar(int xcorr, int ycorr) {
    float returns[] = new float[2];
    returns[0]= degrees(tan(ycorr/xcorr));
    returns[1]= sqrt(pow(xcorr,2)+pow(ycorr,2));
    return returns;
}

float lawCos(int a, int b, int c) {
  return degrees(
     acos(
     (pow(a,2)+pow(b,2)-pow(c,2))/
       (2*a*b)
     )
  );
}
*/
print(0); 

为什么不喜欢我的评论?

Why doesn't it like my comment?

推荐答案

处理以两种不同的模式运行:静态活动

Processing runs in two separate modes: static or active

静态模式只是意味着它是一个指令/调用现有函数的列表(例如绘制一行,然后退出)

Static mode simply means it's a list of instructions/calls to existing functions (e.g. draw a bunch of lines then exit)

Active 模式使用设置() draw()调用和连续运行(每个框架更新)。

Active mode uses the setup() and draw() calls and runs continuously (gets updated every 'frame').

即使你正在使用注释,你在这些注释中定义方法(cortToPolar,lawCos),而Processing会遇到那些是为什么你会得到错误。

Even you though you are using comments, you are defining methods(cortToPolar,lawCos) inside those comments and Processing encounters those which is why you're getting the error.

使用setup()调用打印:

Use the setup() call to do your print:

/*
    float[] cortToPolar(int xcorr, int ycorr) {
    float returns[] = new float[2];
    returns[0]= degrees(tan(ycorr/xcorr));
    returns[1]= sqrt(pow(xcorr,2)+pow(ycorr,2));
    return returns;
}

float lawCos(int a, int b, int c) {
  return degrees(
     acos(
     (pow(a,2)+pow(b,2)-pow(c,2))/
       (2*a*b)
     )
  );
}
*/
void setup(){
  print(0);
}

活动模式下, noLoop()循环( ) draw()

这篇关于处理'看起来你正在混合“活动”和“静态”模式“。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆