cocos creator第一个小游戏:子弹发射 | 血影

这篇博客详细介绍了如何在Cocos Creator中创建一个简单的游戏,玩家通过点击屏幕发射子弹,子弹碰到目标后会更新分数并重新生成新的目标。文章涵盖了游戏逻辑、碰撞检测以及得分系统的实现。
摘要由CSDN通过智能技术生成

制作游戏代码game.js,获取点击事件,发射子弹

cc.Class({
    extends: cc.Component,
    properties: {       
        player: { type:cc.Node, default:null},
        ground: {type:cc.Node,default:null},
        aa: { type:cc.Prefab, default:null},
        bb:{type:cc.Prefab, default:null},
        score:{ type:cc.Label, default:null},
        bullet_Num: 0,
        bullet_Speed : 0,
    },
    mouse (){
        this.node.on(cc.Node.EventType.TOUCH_START,function(event){
            var touch =event.getTouches()[0];
            var position = touch.getLocation();
            var localPosition = this.node.convertToNodeSpaceAR(position);
            this.shutboot(localPosition);
        },
        this
    );
    },
    newgoal(){
        if(this.gg!=null){
            this.gg.destroy();
        }
        va

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值