Arrays 找不到任何名为
这是我第一次犯这个错误,所以我不明白它的意思。这段代码是根据在线教程改编的,这使它更加复杂。在第14行中,我收到错误消息“找不到任何名为‘innerGrid’的内容”。这是指什么?对我来说,代码已经很好地定义了innerGridArrays 找不到任何名为,arrays,2d,cell,processing,Arrays,2d,Cell,Processing,这是我第一次犯这个错误,所以我不明白它的意思。这段代码是根据在线教程改编的,这使它更加复杂。在第14行中,我收到错误消息“找不到任何名为‘innerGrid’的内容”。这是指什么?对我来说,代码已经很好地定义了innerGrid //2d array innerGrid [][] cell; //number of columns int col = 50; //number of rows int row = 10; void setup() { size(500, 100);
//2d array
innerGrid [][] cell;
//number of columns
int col = 50;
//number of rows
int row = 10;
void setup()
{
size(500, 100);
background(0);
//layout grid
innerGrid= new cell[col][row]; //cannot find anything named 'innerGrid'
//write columns (int i) and row numbers (int j) in counters
for (int i = 0; i < col; i ++)
{
for (int j = 0; j < row; i ++)
{
innerGrid[i][j] = new innerGrid(i*10, j*10, 10, i+j);
}
}
//create base layer
initialGrid();
}
void initialGrid()
{
for (int i = 0; i < cols; i ++ )
{
for (int j = 0; j < rows; j ++ )
{
innerGrid[i][j].display();
}
}
}
void draw()
{
for (int i = 0; i < cols; i ++ )
{
for (int j = 0; j < rows; j ++ )
{
innerGrid[i][j].updateColor();
}
}
}
//二维数组
innerGrid[]]单元;
//列数
int col=50;
//行数
int行=10;
无效设置()
{
尺寸(500100);
背景(0);
//布局网格
innerGrid=新单元格[col][row];//找不到任何名为“innerGrid”的内容
//在计数器中写入列(int i)和行号(int j)
for(int i=0;i
这段代码把事情搞糊涂了
要声明一个变量,您需要声明它的类型,innerGrid不是一个类型,除非有一个名为this的类(按照约定,类的首字母应该大写)。看起来您正在寻找的是一个整数的二维数组
但是你会发现很多其他的问题,因为类单元格不存在。。。同理
=新单元格[][]
没有意义,除非有一个类“cell”(没有大写字母…哼哼)不能说。在这种情况下,innerGrid数组应该保存单元格的实例,并声明为
cell[][]innerGrid=新单元格[行][cols]代码>
基本用途如下:
//声明一个int的2D数组
int[]intArray=新int[10][20];
//声明单元格的二维数组
单元格[][]光线=新单元格[10][20];//注意,我们还没有创建任何Cell
//只有一个数组来容纳它们
无效设置(){
for(int i=0;i
您应该为语言添加标签以增加曝光率,这样读者就知道您使用的是哪种语言。它被标记、处理。。。是用于processing.org的
int[][] innerGrid; // int is the type and innerGrid is the name of the var (array)
innerGrid = new int [dim1][dim2]// this also can be done in same line above...