第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

果實(shí)運(yùn)動(dòng)的速度越來越快,求解,已初始化

果實(shí)運(yùn)動(dòng)的速度越來越快,求解,已初始化

正在回答

4 回答

fruitObj.prototype.born?=?function(i)?{

????var?aneId?=?Math.floor(Math.random()?*?ane.num);

????this.x[i]?=?ane.x[aneId];

????this.y[i]?=?canH?-?ane.len[aneId];

????this.l[i]?=?0;

其實(shí)我覺得這里把a(bǔ)ne的實(shí)例化對(duì)象寫進(jìn)去是不妥的。,

? ? var?aneId?=?Math.floor(Math.random()?*?ane.num); ane是實(shí)例化對(duì)象,寫在fruitObj對(duì)象里是不對(duì)的


0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

java家洼

你好,你說“ ane是實(shí)例化對(duì)象,寫在fruitObj對(duì)象里是不對(duì)的”,我覺得你說的不對(duì),因?yàn)閍ne是海葵的實(shí)例對(duì)象,不是果實(shí)的實(shí)例對(duì)象,在果實(shí)類定義中用到其他類的實(shí)例對(duì)象怎么就不行呢?要是用到自己類的實(shí)例對(duì)象才不行呢。你說是不是?
2016-06-23 回復(fù) 有任何疑惑可以回復(fù)我~
var?fruitObj?=?function()?{
	this.x?=?[];
	this.y?=?[];
	this.l?=?[];
	this.alive?=?[];
	this.speed?=?[];
	this.orange?=?new?Image();
	this.blue?=?new?Image();
	this.fruitType?=?[];
}
fruitObj.prototype.num?=?30;
fruitObj.prototype.init?=?function()?{
?	for?(var?i?=?0;?i?<=?this.num;?i++)?{
?		this.alive[i]?=?false;
?		this.x[i]?=?0;
?		this.y[i]?=?0;	
?		this.l[i]?=?0;
?		this.fruitType[i]?=?'';
?		this.speed[i]?=?Math.random()?*?0.0003?+?0.00001;?//[?0.00001?,?0.00051)
?		this.born(i);

?	}
?	this.orange.src?=?'./src/fruit.png';
?	this.blue.src?=?'./src/blue.png';
?}
fruitObj.prototype.draw?=?function()?{
	for?(var?i?=?0;?i?<?this.num;?i++)?{
		if(?this.alive[i]){
			if(?this.fruitType[i]?==?'blue'?){
				var?pic?=?this.blue;
			}else{
				var?pic?=?this.orange;
			}
			if(?this.l[i]?<=?14){
				this.l[i]?+=?this.speed[i]?*?deltaTime;
			}else{
				this.y[i]?-=?this.speed[i]?*?deltaTime;
			}
			ctx2.drawImage(?pic?,?this.x[i]?-?this.l[i]?,?this.y[i]?-?this.l[i]?,?this.l[i]?,?this.l[i]?)
			if(?this.y[i]?<?10?){
				this.alive[i]?=?false;
			}
		}
		
	};
}
fruitObj.prototype.born?=?function(i)?{
	var?aneId?=?Math.floor(Math.random()?*?ane.num);
	this.x[i]?=?ane.x[aneId];
	this.y[i]?=?canH?-?ane.len[aneId];
	this.l[i]?=?0;
	this.alive[i]?=?true;
	var?ran?=?Math.random();
	if(?ran?<?0.3?){
		this.fruitType[i]?=?'blue'
	}else{
		this.fruitType[i]?=?'orange';
	}
}
fruitObj.prototype.fruitManger?=?function()?{
	var?num?=?0;
	for?(var?i?=?0;?i?<?fruit.num;?i++)?{
		if(fruit.alive[i]){
			num++;
		}
	}
	if(?num?<?15?){
		fruit.rebornFruit();
		return;
	}
}
fruitObj.prototype.rebornFruit?=?function()?{
	for?(var?i?=?0;?i?<?fruit.num;?i++)?{
		if(!fruit.alive[i]){
			fruit.born(i);
			return;
		}
	};
};


0 回復(fù) 有任何疑惑可以回復(fù)我~

是啊,而且在出生的時(shí)候,也給this.l[i]=0了

var fruitObj = function() {

this.x = [];

this.y = [];

this.l = [];

this.alive = [];

this.speed = [];

this.orange = new Image();

this.blue = new Image();

this.fruitType = [];

}

fruitObj.prototype.num = 30;

fruitObj.prototype.init = function() {

? for (var i = 0; i <= this.num; i++) {

? this.alive[i] = false;

? this.x[i] = 0;

? this.y[i] = 0;

? this.l[i] = 0;

? this.fruitType[i] = '';

? this.speed[i] = Math.random() * 0.0003 + 0.00001; //[ 0.00001 , 0.00051)

? this.born(i);


? }

? this.orange.src = './src/fruit.png';

? this.blue.src = './src/blue.png';

?}

fruitObj.prototype.draw = function() {

for (var i = 0; i < this.num; i++) {

if( this.alive[i]){

if( this.fruitType[i] == 'blue' ){

var pic = this.blue;

}else{

var pic = this.orange;

}

if( this.l[i] <= 14){

this.l[i] += this.speed[i] * deltaTime;

}else{

this.y[i] -= this.speed[i] * deltaTime;

}

ctx2.drawImage( pic , this.x[i] - this.l[i] , this.y[i] - this.l[i] , this.l[i] , this.l[i] )

if( this.y[i] < 10 ){

this.alive[i] = false;

}

}

};

}

fruitObj.prototype.born = function(i) {

var aneId = Math.floor(Math.random() * ane.num);

this.x[i] = ane.x[aneId];

this.y[i] = canH - ane.len[aneId];

this.l[i] = 0;

this.alive[i] = true;

var ran = Math.random();

if( ran < 0.3 ){

this.fruitType[i] = 'blue'

}else{

this.fruitType[i] = 'orange';

}

}

fruitObj.prototype.fruitManger = function() {

var num = 0;

for (var i = 0; i < fruit.num; i++) {

if(fruit.alive[i]){

num++;

}

}

if( num < 15 ){

fruit.rebornFruit();

return;

}

}

fruitObj.prototype.rebornFruit = function() {

for (var i = 0; i < fruit.num; i++) {

if(!fruit.alive[i]){

fruit.born(i);

return;

}

};

};


0 回復(fù) 有任何疑惑可以回復(fù)我~

? if (this.alive[i]) {

? ? ? ? ? ?if (this.l[i] <= 14) {

? ? ? ? ? ?this.l[i] += this.spd[i] * deltaTime;

? ? ? ? ? ?}

? ? ? ? ? ?else{

? ? ? ? this.y[i] -= this.spd[i] * 7 * deltaTime;

? ? ? ? ? ?}

你的代碼是這樣嗎,我這樣寫的沒有問題哦


0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

果實(shí)運(yùn)動(dòng)的速度越來越快,求解,已初始化

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)