課程
/前端開發(fā)
/HTML/CSS
/HTML5小游戲---愛心魚(下)
代碼看了好幾遍都是一樣的但是就是打印不出來
2016-07-02
源自:HTML5小游戲---愛心魚(下) 3-5
正在回答
halo.JS
haloObj.prototype.born=function(x,y)
{
for(var i=0;i<this.num;i++)
if(!this.alive[i])
this.x[i]=x;
this.y[i]=y;
this.r[i]=10;
this.alive[i]=true;
}
代碼遺落了一個(gè)? ? ? ? “ !”字符
if(!this.alive[i])? ? ? ? ? ?加上就好了“ !”字符
已解決,忘記改成初始化this.alive[i] == true
慕仔8415870
var haloObj = function()
this.x = [];
this.y = [];
this.alive = [];
this.r = [];
haloObj.prototype.num = 5;
haloObj.prototype.init = function()
for (var i = 0; i < this.num; i++)
this.x[i] = 0;
this.y[i] = 0;
this.alive[i] = false;
this.r[i] = 0;
haloObj.prototype.draw = function()
ctx1.save();
ctx1.lineWidth = 2;
ctx1.shadowBlur = 10;
ctx1.shadowColor = "rgba(123,123,123,1)";
for (var i = 0; i < this.num ;i++)
if (this.alive[i])
alert("123");
this.r[i] += deltaTime * 0.05;
if (this.r[i] > 100)
break;
var alpha = 1 - this.r[i] / 100;
ctx1.beginPath();
ctx1.arc(this.x[i], this.y[i], this.r[i], 0 , Math.PI *2);
ctx1.closePath();
ctx1.strokeStyle = "rgba(123,123,123,"+ alpha +")";
ctx1.stroke();
ctx1.restore();
haloObj.prototype.born = function(x, y)
this.x[i] = x;
this.y[i] = y;
this.r[i] = 10;
this.alive[i] = true;?
return;
vanish_
這位同學(xué),能把代碼貼出來看一下嗎? ?
舉報(bào)
通過一個(gè)清新美好的小游戲教程,熟悉游戲開發(fā)流程
2 回答draw出不來?小魚特效沒出?
1 回答繪制小魚身體動(dòng)畫時(shí)出錯(cuò),導(dǎo)致前面繪制的都出不來了
2 回答大魚繪制出現(xiàn)問題
2 回答draw里面if語句執(zhí)行的問題
3 回答為什么控制臺(tái)沒有顯示錯(cuò)誤但是就是不顯示下面draw函數(shù)寫上的內(nèi)容
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2020-04-27
halo.JS
haloObj.prototype.born=function(x,y)
{
for(var i=0;i<this.num;i++)
{
if(!this.alive[i])
{
this.x[i]=x;
this.y[i]=y;
this.r[i]=10;
this.alive[i]=true;
}
}
}
代碼遺落了一個(gè)? ? ? ? “ !”字符
if(!this.alive[i])? ? ? ? ? ?加上就好了“ !”字符
2017-01-26
已解決,忘記改成初始化this.alive[i] == true
2017-01-26
var haloObj = function()
{
this.x = [];
this.y = [];
this.alive = [];
this.r = [];
}
haloObj.prototype.num = 5;
haloObj.prototype.init = function()
{
for (var i = 0; i < this.num; i++)
{
this.x[i] = 0;
this.y[i] = 0;
this.alive[i] = false;
this.r[i] = 0;
}
}
haloObj.prototype.draw = function()
{
ctx1.save();
ctx1.lineWidth = 2;
ctx1.shadowBlur = 10;
ctx1.shadowColor = "rgba(123,123,123,1)";
for (var i = 0; i < this.num ;i++)
{
if (this.alive[i])
{
alert("123");
this.r[i] += deltaTime * 0.05;
if (this.r[i] > 100)
{
this.alive[i] = false;
break;
}
var alpha = 1 - this.r[i] / 100;
ctx1.beginPath();
ctx1.arc(this.x[i], this.y[i], this.r[i], 0 , Math.PI *2);
ctx1.closePath();
ctx1.strokeStyle = "rgba(123,123,123,"+ alpha +")";
ctx1.stroke();
}
}
ctx1.restore();
}
haloObj.prototype.born = function(x, y)
{
for (var i = 0; i < this.num; i++)
{
if (this.alive[i])
{
this.x[i] = x;
this.y[i] = y;
this.r[i] = 10;
this.alive[i] = true;?
return;
}
}
}
2016-07-04
這位同學(xué),能把代碼貼出來看一下嗎? ?