如果查看脚本的最底部,可以看到函数interval()。不起作用的部分是bc-(AEfficiency * 100)/ 5; monz +((AEfficiency * 100)/ 5)的((AFluency AProduct)/ 100); 值“bc”和“monz”没有变化。为什么?在运行html文件时单击“生成经销商”后,将发生此更改。请帮助。
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Sweetness Overload</title>
<style>
body{
font-size:20px;
margin:0;
overflow:hidden;
}
#sweets{
font-size:30px;
position:fixed;
top:1.0%;
left:1.0%;
text-align:center;
user-select:none;
-moz-user-select:none;
-khtml-user-select:none;
-webkit-user-select:none;
-o-user-select:none;
}
#sweets:hover{
text-decoration:underline;
cursor:pointer;
}
#sweetsMenu{
display:none;
position:fixed;
top:6.0%;
left:0%;
padding:0.5em 0.5em;
text-align:left;
vertical-align:top;
background-color:lightgray;
border:2px outset lightgray;
}
#sweetsMenu div{
margin:0.0em 0em;
}
#sweetsMenu p{
margin:0.5em 0em;
}
#dealers{
font-size:30px;
position:fixed;
top:1.0%;
right:1.0%;
text-align:center;
user-select:none;
-moz-user-select:none;
-khtml-user-select:none;
-webkit-user-select:none;
-o-user-select:none;
}
#dealers:hover{
text-decoration:underline;
cursor:pointer;
}
#dealersMenu{
display:none;
position:fixed;
top:6.0%;
right:0%;
padding:0.5em 0.5em;
text-align:left;
vertical-align:top;
background-color:lightgray;
border:2px outset lightgray;
}
#dealersMenu div{
margin:0.0em 0em;
}
#dealersMenu p{
margin:0.5em 0em;
}
#cash{
font-size:30px;
position:absolute;
bottom:1.0%;
width:100%;
text-align:center;
user-select:none;
-moz-user-select:none;
-khtml-user-select:none;
-webkit-user-select:none;
-o-user-select:none;
}
#cash:hover{
cursor:default;
}
#click{
user-select: none;
-moz-user-select: none;
-khtml-user-select: none;
-webkit-user-select: none;
-o-user-select: none;
}
#click:hover{
text-decoration: underline;
cursor: pointer;
}
#bc5{
color:gray;
float:right;
user-select: none;
-moz-user-select: none;
-khtml-user-select: none;
-webkit-user-select: none;
-o-user-select: none;
}
#AProperties{
display:none;
color:gray;
float:right;
user-select: none;
-moz-user-select: none;
-khtml-user-select: none;
-webkit-user-select: none;
-o-user-select: none;
}
</style>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-33914917-1']);
_gaq.push(['_setDomainName', 'dhmholley.co.uk']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body onload="initialise()">
<div id="blackBox2">
<div id="blackBox"></div>
</div>
<div id="cash">
<span id="monz"></span>
</div>
<div id="sweets" onclick="toggleSweets()">Sweets</div>
<div id="sweetsMenu">
<div id="click" onclick="buyBC()">Bulk Candy (<span id="bccost"></span>)</div>
<div id="txt"><span id="bc"></span> <span id="bc5"></span></div>
</div>
<div id="dealers" onclick="toggleDealers()">Dealers</div>
<div id="dealersMenu">
<div id="click" onclick="genDeal()">Generate Dealer (<span id="crntdeal"></span>/<span id="maxdeal"></span>)</div>
<div id="txt"><span id="dealerA"></span> <span id='AProperties'></span></div>
</div>
<script>
var monz = 10000;
timer = 0;
crntdeal = 0;
maxdeal = 1;
genEfficiency = 0;
genFluency = 0;
bccost = 1500;
bcr = 180;
bcp = 0;
bc = 0;
bc5 = bc * 5;
bcprice = 500;
dealerA = 'A';
AEfficiency = 0;
AFluency = 0;
AProduct = bcprice;
function initialise(){
getCash();
getSweets();
getDealers();
setInterval(interval,25);
}
function getCash(){
document.getElementById('cash').innerHTML = monz / 100 + "$";
}
function getSweets(){
bc5 = bcp * 5;
document.getElementById('bccost').innerHTML = bccost / 100 + "$";
document.getElementById('bc').innerHTML = bc / 100 + "g";
document.getElementById('bc5').innerHTML = bc5 / 100 + "g/sec";
}
function getDealers(){
document.getElementById('crntdeal').innerHTML = crntdeal;
document.getElementById('maxdeal').innerHTML = maxdeal;
document.getElementById('dealerA').innerHTML = dealerA;
document.getElementById('AProperties').innerHTML = (AProduct*AFluency)/100+"$/g"+" | "+AEfficiency+"g/sec";
}
function toggleSweets(){
var sweetsMenu = document.getElementById('sweetsMenu');
if (sweetsMenu.style.display != 'block'){
sweetsMenu.style.display = 'block';
} else {
sweetsMenu.style.display = 'none';
}
}
function toggleDealers(){
var dealersMenu = document.getElementById('dealersMenu');
if (dealersMenu.style.display != 'block'){
dealersMenu.style.display = 'block';
} else {
dealersMenu.style.display = 'none';
}
}
function buyBC(){
if (monz >= bccost){
monz = monz - bccost;
bccost = bccost + bcr;
bcr = bcr + 25;
bcp += 4;
}
}
function genDeal(){
if (crntdeal < maxdeal){
genEfficiency = Math.floor((Math.random() * 5) + 1);
genFluency = Math.floor((Math.random() * 5) + 1);
if (crntdeal == 0){
AFluency = genFluency * 0.1 + 1;
AEfficiency = genEfficiency;
AProperties = document.getElementById('AProperties');
AProperties.style.display = 'block';
}
crntdeal ++;
getDealers();
}
}
function interval(){
timer ++;
if (timer >= 8){
bc += bcp
if (bc >= (AEfficiency*100)/5){
bc-(AEfficiency*100)/5;
monz+((AEfficiency*100)/5)*((AFluency*AProduct)/100);
}
timer = 0;
}
getCash();
getSweets();
}
</script>
</body>
</html>
答案 0 :(得分:1)
将其更改为
bc-=(AEfficiency*100)/5;
monz+=((AEfficiency*100)/5)*((AFluency*AProduct)/100);
你需要在那里实际设置值。