1
我正在進行空閒/點擊遊戲,當我嘗試購買手臂時,它根本沒有做任何事情。我已經嘗試了幾乎所有我知道的事情,並且我無法通過搜索互聯網獲得任何結果。購買不工作的閒置遊戲
HTML:
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/interface.css" />
<title>Jujhar Clicker</title>
</head>
<body>
<script type="text/javascript" src="js/main.js"></script>
<div style="position: absolute; top: 30px; right: 660px;"><button id="Face" onClick="faceClick(1)" style="position: static" align="center"><img src="images/face.png"><p align="center" style="line-height:-200em">Click Me!</p></button></div>
<div style="position: absolute; top: 10px; right: 690px;"><a>Faces: </a><span id="faces" style="right:20px">0</span></div>
<button id="RoboticArm" onClick="buyArm" style="position: static" align="center"><img src="images/ArmStore.png" /></button>
<div style="position: absolute; left: 20px;"><span id="arms">Amount: 0</span>
<a>Cost: </a>
<span id="armCost">10</span></div>
</body>
</html>
的Javascript:
var faces = 0;
var arms = 0;
function faceClick(number) {
faces = faces + number;
document.getElementById("faces").innerHTML = faces;
};
function buyArm() {
var armCost = Math.floor(10 * Math.pow(1.1,arms));
if (faces >= armCost) {
arms = arms + 1;
faces = faces - armCost;
document.getElementById('arms').innerHTML = "Amount: " + arms;
document.getElementById('faces').innerHTML = faces;
};
var nextCost = Math.floor(10 * Math.pw(1.1,arms));
document.getElementById('armCost').innerHTML = nextCost;
};
看起來你拼錯了'Math.pow' – Jackson