这是增量游戏的JSFiddle:https://jsfiddle.net/y69sh3nc/
我有函数getAutoClicker()
var AutoClickers = 0;
var AutoClickerCost = 10;
function getAutoClicker(){
if(cookieClicks >= AutoClickerCost){
AutoClickers++;
cookieClicks -= AutoClickerCost;
AutoClickerCost += Math.floor(AutoClickerCost*.3);
} else{
alert("Oh No! It appears you do not have enough cookies to purchase an Auto Clicker. An Auto Clicker currently costs "+AutoClickerCost+" which is "+(AutoClickerCost-cookieClicks)+" more cookies than you have.")
}
}
我不想为getAutoClickerTwo()
编写另一个函数,因为我不想重复自己。
如何编写函数并将其用于我想要的多个自动答题器?
当我尝试编写一个通用函数并使用不同的参数为每个按钮调用它时它不起作用,因为变量不会在其他函数中更新。