我正在使用默认的JFrame gui 进行粗略的空闲游戏(想想CookieClicker).货币单位是"点击",一旦获得足够的"点击",玩家应该能够点击与他们可以购买的自动转换相对应的JButton.但是,只有最后一个'autoclicker'添加到自动链接器的ArrayList才能在正确的时间可用,如果单击它,则所有其他JButton都会使用其属性.如果可能的话,你能帮我解决问题吗?免责声明:可能是一堆故障排除.
这是我的主类:(我有额外的JButtons和AutoClickers注释掉,所以它按预期工作)
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Arrays;
import javax.swing.*;
public class Main extends JFrame /*implements Runnable*/{
static double clickCount = 0D;
static double cpst = 0D;
static JFrame frameMain = new JFrame("Clicker - Evan");
static JLabel labelCount = new JLabel("Click Count: " + clickCount);
static JLabel labelcps = new JLabel("Click Per Second: " + cpst);
static ArrayList<AutoClicker> clickers = new ArrayList<AutoClicker>(/*Arrays.asList(AutoClicker("Mouse", 1, 10))*/);
static ArrayList<JButton> buttonAuto = new ArrayList<JButton>();
static JButton …Run Code Online (Sandbox Code Playgroud)