猫史档案馆


捡抢代码教程

用户:datacatdatacat查看:521 回复:16 评论:33 创建时间:2020-04-15T15:04:26


还是为了升级,看见猴急说要180个教程贴啊啊啊

emotion_编程猫_翻白眼emotion_编程猫_翻白眼emotion_编程猫_翻白眼emotion_编程猫_翻白眼emotion_编程猫_翻白眼emotion_编程猫_翻白眼

话不对说开始!!!

别问我为什么不是得分代码

首先非常简单,先做一个喵的模型(或多个)

然后加一个标签,这个标签随便加

让后加这个代码

world.querySelectorAll('.喵').forEach((喵)=>{
    喵.onEntityContact(({other})=>{  
        if(is_contact_喵[find(all_player_name,other.player.name)]===false){

这个代码就是,开始时玩家不能喵的意思,只有捡抢后才能攻击

emotion_编程猫_冷漠

 

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

      emotion_雷电猴_举手

这个代码

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;

就是这样,没有写全哈哈

emotion_雷电猴_捂嘴笑

让后再加个提示语

 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;

提示语你们可以自己编,哈哈

emotion_雷电猴_围观

让后再加个这个

喵.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;
    });
});

怎么样,你学会了吗

哦要写下一个教程贴了

emotion_编程猫_加油emotion_编程猫_加油emotion_编程猫_加油emotion_编程猫_加油emotion_编程猫_加油emotion_编程猫_加油emotion_编程猫_加油


回复

上一页第 1 页 / 共 1 页下一页
HXS咫尺已天涯HXS咫尺已天涯

哈哈哈,加油

点赞0


评论

这是我的代码啊啊啊啊。。。555

我看出来了

哈哈哈

你来玩吗?

这个看出来很容易

哪个

我去过一次了

去城市空战

我现在在那里

我现在不想去,等一会吧

已经建了好多啦

难道你不想来看看吗?

还是你爸在旁边?

在吗?

在,等一会

好吧。。。

你是人吗(开玩笑,你的名字太像官方了)

官方也是人……

莱利,你快点到代码岛首页的游戏里看看,有一个叫跑酷的图,有惊喜,快看看

莱利你在吗

在在在

在吗,新图开始没

那个市长喵qq了

新图开始了https://box3create.codemao.cn/games/c74777d725a21b1da喵5

在不?

https://box3create.codemao.cn/games/edc9f12d35556476f6c4


高贵的木叶龙A35d高贵的木叶龙A35d

666,老铁没毛病

点赞0


评论


_F_S_2__F_S_2_

额

 

点赞0


评论


_F_S_2__F_S_2_

这不是人工智能AI教我的吗

点赞0


评论


高贵的木叶龙A35d高贵的木叶龙A35d

没有用啊?

点赞0


评论

碰枪没效果

你加标签了吗

要两个

加了

没用!

确实捡不了枪啊!!


高贵的木叶龙A35d高贵的木叶龙A35d

报错了!什么情况!

点赞0


评论

坑我嗄


DASKDASK

可以啊

点赞0


评论


datacatdatacat

dd,那个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


评论


ssssSSSAssssSSSA

cy

点赞0


评论


燎原烈火燎原烈火

怎么捡枪

 

点赞0


评论


锦衣侠客锦衣侠客

emmmm

点赞0


评论


yyds二营长yyds二营长

ddd

点赞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


评论


仙之鹤仙之鹤

emotion_编程猫_点赞

点赞0


评论


黑客熊猫黑客熊猫

额,《话不对说》

点赞0


评论


追梦ez追梦ez

抢代码教程(幻视)

点赞0


评论