用户:
datacat查看:521 回复:16 评论:33 创建时间:2020-04-15T15:04:26
还是为了升级,看见猴急说要180个教程贴啊啊啊






话不对说开始!!!
别问我为什么不是得分代码
首先非常简单,先做一个喵的模型(或多个)
然后加一个标签,这个标签随便加
让后加这个代码
world.querySelectorAll('.喵').forEach((喵)=>{
喵.onEntityContact(({other})=>{
if(is_contact_喵[find(all_player_name,other.player.name)]===false){
这个代码就是,开始时玩家不能喵的意思,只有捡抢后才能攻击

那怎么让玩家可以捡抢并攻击呢?

这个代码
if(喵.hasTag('1')){
attack_power[find(all_player_name,other.player.name)]=2;
} else if(喵.hasTag('2')){
就是给喵再加个标签,比如这个喵的等级是2,那第2个标签就是2
如果再加几个等级呢
if(喵.hasTag('1')){
attack_power[find(all_player_name,other.player.name)]=2;
} else if(喵.hasTag('2')){
attack_power[find(all_player_name,other.player.name)]=5;
} else if(喵.hasTag('3')){
attack_power[find(all_player_name,other.player.name)]=10;
} else if(喵.hasTag('4')){
attack_power[find(all_player_name,other.player.name)]=20;
就是这样,没有写全哈哈

让后再加个提示语
world.say(other.player.name+'捡起了喵');
world.say('攻击力为'+attack_power[find(all_player_name,other.player.name)]);
is_contact_喵[find(all_player_name,other.player.name)]=true;
提示语你们可以自己编,哈哈

让后再加个这个
喵.onEntitySeparate(({other})=>{
is_contact_喵[find(all_player_name,other.player.name)]=false;
就可以了,我再给大家看个全代码
world.querySelectorAll('.喵').forEach((喵)=>{
喵.onEntityContact(({other})=>{
if(is_contact_喵[find(all_player_name,other.player.name)]===false){
if(喵.hasTag('1')){
attack_power[find(all_player_name,other.player.name)]=2;
} else if(喵.hasTag('2')){
attack_power[find(all_player_name,other.player.name)]=5;
} else if(喵.hasTag('3')){
attack_power[find(all_player_name,other.player.name)]=10;
} else if(喵.hasTag('4')){
attack_power[find(all_player_name,other.player.name)]=20;
}
world.say(other.player.name+'捡起了喵');
world.say('攻击力为'+attack_power[find(all_player_name,other.player.name)]);
is_contact_喵[find(all_player_name,other.player.name)]=true;
}
});
喵.onEntitySeparate(({other})=>{
is_contact_喵[find(all_player_name,other.player.name)]=false;
});
});
怎么样,你学会了吗
哦要写下一个教程贴了







哈哈哈,加油
点赞0
评论
这是我的代码啊啊啊啊。。。555
我看出来了
哈哈哈
你来玩吗?
这个看出来很容易
哪个
我去过一次了
去城市空战
我现在在那里
我现在不想去,等一会吧
已经建了好多啦
难道你不想来看看吗?
还是你爸在旁边?
在吗?
在,等一会
好吧。。。
你是人吗(开玩笑,你的名字太像官方了)
官方也是人……
莱利,你快点到代码岛首页的游戏里看看,有一个叫跑酷的图,有惊喜,快看看
莱利你在吗
在在在
在吗,新图开始没
那个市长喵qq了
新图开始了https://box3create.codemao.cn/games/c74777d725a21b1da喵5
在不?
https://box3create.codemao.cn/games/edc9f12d35556476f6c4
datacatdd,那个find函数代码如下
function (arr, obj) {
if (!typeof (arr) == Array) return;
var i = arr.length;
for (let j = 0; j <= i; j++) {
if (arr[j] == obj) {
return j;
} else { return false; }
//*遍历数组arr
}
}点赞0
评论
馫龘飝鱻灥麤靐飍朤馫譶龘飝虪齺world.querySelectorAll('.喵').forEach((喵)=>{
喵.onEntityContact(({other})=>{
if(is_contact_喵[find(all_player_name,other.player.name)]===false){
if(喵.hasTag('1')){
attack_power[find(all_player_name,other.player.name)]=2;
} else if(喵.hasTag('2')){
attack_power[find(all_player_name,other.player.name)]=5;
} else if(喵.hasTag('3')){
attack_power[find(all_player_name,other.player.name)]=10;
} else if(喵.hasTag('4')){
attack_power[find(all_player_name,other.player.name)]=20;
}
world.say(other.player.name+'捡起了喵');
world.say('攻击力为'+attack_power[find(all_player_name,other.player.name)]);
is_contact_喵[find(all_player_name,other.player.name)]=true;
}
});
喵.onEntitySeparate(({other})=>{
is_contact_喵[find(all_player_name,other.player.name)]=false;
});
});
world.querySelectorAll('.喵').forEach((喵)=>{ 喵.onEntityContact(({other})=>{ if(is_contact_喵[find(all_player_name,other.player.name)]===false){ if(喵.hasTag('1')){ attack_power[find(all_player_name,other.player.name)]=2; } else if(喵.hasTag('2')){ attack_power[find(all_player_name,other.player.name)]=5; } else if(喵.hasTag('3')){ attack_power[find(all_player_name,other.player.name)]=10; } else if(喵.hasTag('4')){ attack_power[find(all_player_name,other.player.name)]=20; } world.say(other.player.name+'捡起了喵'); world.say('攻击力为'+attack_power[find(all_player_name,other.player.name)]); is_contact_喵[find(all_player_name,other.player.name)]=true; } }); 喵.onEntitySeparate(({other})=>{ is_contact_喵[find(all_player_name,other.player.name)]=false; }); });
world.querySelectorAll('.喵').forEach((喵)=>{ 喵.onEntityContact(({other})=>{ if(is_contact_喵[find(all_player_name,other.player.name)]===false){ if(喵.hasTag('1')){ attack_power[find(all_player_name,other.player.name)]=2; } else if(喵.hasTag('2')){ attack_power[find(all_player_name,other.player.name)]=5; } else if(喵.hasTag('3')){ attack_power[find(all_player_name,other.player.name)]=10; } else if(喵.hasTag('4')){ attack_power[find(all_player_name,other.player.name)]=20; } world.say(other.player.name+'捡起了喵'); world.say('攻击力为'+attack_power[find(all_player_name,other.player.name)]); is_contact_喵[find(all_player_name,other.player.name)]=true; } }); 喵.onEntitySeparate(({other})=>{ is_contact_喵[find(all_player_name,other.player.name)]=false; }); });
world.querySelectorAll('.喵').forEach((喵)=>{ 喵.onEntityContact(({other})=>{ if(is_contact_喵[find(all_player_name,other.player.name)]===false){ if(喵.hasTag('1')){ attack_power[find(all_player_name,other.player.name)]=2; } else if(喵.hasTag('2')){ attack_power[find(all_player_name,other.player.name)]=5; } else if(喵.hasTag('3')){ attack_power[find(all_player_name,other.player.name)]=10; } else if(喵.hasTag('4')){ attack_power[find(all_player_name,other.player.name)]=20; } world.say(other.player.name+'捡起了喵'); world.say('攻击力为'+attack_power[find(all_player_name,other.player.name)]); is_contact_喵[find(all_player_name,other.player.name)]=true; } }); 喵.onEntitySeparate(({other})=>{ is_contact_喵[find(all_player_name,other.player.name)]=false; }); });点赞0
评论