猫史档案馆


【教程】【补更】切换喵&射击代码&开火冷却

用户:老葵老葵查看:539 回复:9 评论:13 创建时间:2020-06-13T15:22:13


话不多说,直接上代码

world.onPlayerJoin(({ entity }) => {
    entity.enableDamage = true;
    entity.player.Qiang = 0;
    entity.player.Lengque = 0;
    entity.player.directMessage('请务必快去找喵!落地是没有喵的!')
    entity.player.onPress(async({ button, raycast:{ hitEntity, direction } }) => {
        if (button !== 'action0' || !hitEntity) {
            return;
        }
        hitEntity.velocity.x += direction.x;
        hitEntity.velocity.y += direction.y;
        hitEntity.velocity.z += direction.z;
        if(entity.player.Lengque == 0){
            if(entity.player.Qiang == 1){
                hitEntity.hurt(10);
                entity.player.Lengque = 1;
                await sleep(100);//静待一段时间,time是输入的参数,默认值为1000毫秒
                entity.player.Lengque = 0;
            }
            else if(entity.player.Qiang == 2){
                hitEntity.hurt(80);
                entity.player.Lengque = 1;
                await sleep(100);//静待一段时间,time是输入的参数,默认值为1000毫秒
                entity.player.Lengque = 0;    
            }
            else if(entity.player.Qiang == 3){
                hitEntity.hurt(40);
                entity.player.Lengque = 1;
                await sleep(600);
                entity.player.Lengque = 0;
            }
        }
    });
});

加标签,开实体

1是冲锋喵

2是喵喵

3是喵

还有加这段代码

world.querySelectorAll('.1').forEach((e)=>{
    e.onEntityContact(({entity,other})=>{
        other.player.Qiang=1;
        world.say(other.player.name + ' 捡到了冲锋喵');
    })
})
world.querySelectorAll('.2').forEach((e)=>{
    e.onEntityContact(({entity,other})=>{
        other.player.Qiang=3;
        world.say(other.player.name + ' 捡到了喵喵');
    })
})
world.querySelectorAll('.3').forEach((e)=>{
    e.onEntityContact(({entity,other})=>{
        other.player.Qiang=2;
        world.say(other.player.name + ' 捡到了喵');
    })
})

就没了

再见

(赶时间做作业)


回复

上一页第 1 页 / 共 1 页下一页
老葵老葵

本来打算详细讲一讲,但是要做作业了(沙发)

点赞0


评论

哇,我之前的换枪代码也是用喵作为私人变量

忽然发现,你的头像和我的很搭

请问你会发射子弹的粒子效果吗

栗子特效

我知道是粒子

但是怎么让粒子在我点击鼠标时往我的准心方向发射

将粒子的发射方向调为玩家的方向。

那代码呢

噗,明明是检测射线

ee

上面那个是干嘛的

上面那个是干嘛的,老葵

射击代码主体(核心),下面是枪械选择的


GZ006GZ006

谢谢

点赞0


评论


ZCH无聊喵ZCH无聊喵

沙发

点赞0


评论


GZ006GZ006

请问你会让粒子在我点击鼠标时往我的准心方向发射的效果吗

点赞0


评论


两个小八路两个小八路

emotion_编程猫_加油

点赞0


评论


老葵老葵

第六期呀

点赞0


评论


DoooooveDooooove

妙a

点赞0


评论


yyds二营长yyds二营长

前面几期的帖子呢?

点赞0


评论


黑客熊猫黑客熊猫

挖坟

点赞0


评论