Eclipse 和处理 PApplet 错误

Eclipse and Processing PApplet Error

目前我正在尝试制作一个迷宫游戏。我只是想加载精灵并让程序运行,但它无法正常工作并给我一条错误消息: 用法:PApplet [选项] [草图参数] 有关解释,请参阅 PApplet 的 Javadoc。 我已经阅读了一些有某种解决方案的答案,但是我不知道他们在说什么,因为我是一个 13 岁的 beginner/intermediate 程序员。这是给我错误消息的代码:

package MegaPackage;
import java.util.*;
import processing.core.PApplet;
import processing.core.PImage;
//Main method. Insert public variables and entities here.
public class FlatShooter extends PApplet {
PImage background;
PImage squareImage;
PImage life1Image;
PImage life2Image;
PImage life3Image;
PImage redEnemyImage;
public float xSpeedPlayer = 9;
public int score;
public int enemies;
public int lives;
public boolean moving = false;
public boolean moving2 = false;
public Square square;
public void setup(){
    size(900, 900);
    background=loadImage("background.jpeg");
    squareImage=loadImage("player.png");
    life1Image=loadImage("life.png");
    life2Image=loadImage("life.png");
    life3Image=loadImage("life.png");
    square = new Square(squareImage, (width-100)/2, height * 4/5);
}
//Movement for player and other items
public void keyPressed(){
    if( key == 'd' || key == 'D'){
        moving = true;
    }
    if(key == 'a' || key == 'A'){
        moving2 = true;
    }
}
//Stopping movement for players and other items
public void keyReleased(){
    if( key == 'd' || key == 'D'){
        moving = false;
    }
    if(key == 'a' || key == 'A'){
        moving2 = false;
    }
}
public class Square{
    PImage square;
    float xPos;
    float yPos;     
    public Square(PImage squareImage, float startX, float startY){
        square=squareImage;
        xPos=startX;
        yPos=startY;
    }
public void drawSquare(){
    image(square, xPos, yPos);
}
}
public void move(float x, float y){
    if(moving){
        x += xSpeedPlayer;
    }
    if (moving2){
        x-= xSpeedPlayer;
        }
    }
}

如果您能用相当简单的术语和简单的解决方案给出这个答案,请这样做。谢谢。

我猜您是在使用过时的教程?从处理 3 开始,PApplet class 不再扩展 Applet class,因此您不能 运行 它作为小程序。

相反,您必须添加一个 main() 方法,然后调用 PApplet.runSketch()

无耻的自我推销:我写了一篇关于使用 Processing 作为 Java 可用库的教程 here

但是,如果您刚刚起步,那么在跳转到使用 Eclipse 进行更高级的编程之前,您真的可能想花一些时间在 Processing 编辑器中。