Cocos笔记

1// 判断是不是移动平台 2cc.sys.isMobile 3 4 5// 动画系统 6this.anim = this.getComponent(cc.Animation) as cc.Animation; 7 8 9// 全场最佳 唯一 ,跨场景存活 10cc.game.addPersistRootNode(this.node); 11 12 13// 监听按键事件 14cc.systemEvent.on(cc.SystemEvent.EventType.KEY_UP, this.onKeyUp, this) 15cc.systemEvent.on(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this) 16 17// 注销按键事件 18cc.systemEvent.off(cc.SystemEvent.EventType.KEY_UP, this.onKeyUp, this); 19cc.systemEvent.off(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this); 20 21/** 22 * 键盘弹起事件 23 * @param event 24 */ 25onKeyUp(event: KeyboardEvent){ ... } 26 27 28// 监听触摸移动事件 29this.node.on(cc.Node.EventType.TOUCH_MOVE, this.onMove, this); 30// 注销触摸移动事件 31this.node.off(cc.Node.EventType.TOUCH_MOVE, this.onMove, this); 32 33/** 34 * 移动设备,手指移动,玩家飞机跟着跑 35 */ 36onMove(event: cc.Event.EventTouch) { 37 this.node.position = event.getLocation() 38} 39 40 41// 开启碰撞检测 42let manager = cc.director.getCollisionManager(); 43manager.enabled = true; 44// 碰撞检测系统的 debug 绘制 45manager.enabledDebugDraw = true; 46 47/** 48 * 碰撞事件发生时 49 * @param other 对方节点 50 * @param self 自己的节点 51 */ 52onCollisionEnter(other: cc.Collider, self: cc.Collider) { 53 // 如果是敌机,或者敌机的子弹,直接boom,结算积分嘲讽一波 54 if (!this.HAS_BOOM && (other.node.group == 'b_enemy' || other.node.group == 'enemy')) { 55 this.HAS_BOOM = true; 56 this.boom(); 57 } 58} 59 60 61// 界面跳转 62cc.director.loadScene('launch');
点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

SpringBoot整合Redis乱码原因及解决方案

问题描述:springboot使用springdataredis存储数据时乱码rediskey/value出现\\xAC\\xED\\x00\\x05t\\x00\\x05问题分析:查看RedisTemplate类!(https://oscimg.oschina.net/oscnet/0a85565fa

SpringBoot使用RedisTemplate操作Redis时,key值出现 -xac-xed-x00-x05t-x00-tb

原因分析原因与RedisTemplate源码中的默认序列化方式有关defaultSerializernewJdkSerializationRedisSerializer(classLoader!null?classLoader:this.getClass().getClassLoader()