Creator打地鼠游戏hitmouse.zip // Learn cc.Class: // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/class.html // - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html // Learn Attribute: // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html // - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html // - [English] https://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html cc.Class({ extends: cc.Component, properties: { mouse: [cc.Node], hammer: cc.Node, txtCount: cc.Label, }, // LIFE-CYCLE CALLBACKS: onLoad () { var manager = cc.director.getCollisionManager(); manager.enabled = true; this.count = 0; this.txtCount.string = this.count; }, start () { cc.director.getScheduler().schedule(this.logic, this, 0.5, false); this.node.on(cc.Node.EventType.TOUCH_START, function(event){ for(let i = 0; i < this.mouse.length; i++){ if(this.mouse[i].opacity == 0){ continue; } let parent = this.mouse[i].parent; let maskPos = parent.parent.convertToWorldSpaceAR(parent.position); let maskRect = cc.rect(maskPos.x - parent.width / 2 , maskPos.y , parent.width, parent.height); let mouse = this.mouse[i]; let mousePos = parent.convertToWorldSpaceAR(mouse.position); let mousRect = cc.rect(mousePos.x - mouse.width / 2, mousePos.y - mouse.height / 2, mouse.width, mouse.height); let mixRect = new cc.Rect(); maskRect.intersection(mixRect, mousRect); if(mixRect.contains(event.getLocation())){ this.hammer.position = parent.position; this.hammer.active = true; this.count++; this.txtCount.string = this.count; break; } } }, this); this.node.on(cc.Node.EventType.TOUCH_END, function(event){ this.hammer.active = false; }, this); }, logic(){ let index = Math.floor(Math.random() * 9); cc.log(`index:${index}`); if(index < 0 || index >= this.mouse.length){ return; } this.mouse[index].getComponent('mouse').appear(); }, // update (dt) {}, });
2022-09-23 16:05:12 468KB Creator打地鼠
1
Scratch游戏项目
2022-09-03 19:06:37 414KB scratch
1
前言在开始构建我们的游戏之前,让我们从GitHub下载教程。你也可以下载已完成的版本,但是首先尝试与我们一起构建你的游戏。如果你在我们的教程中遇到麻烦,请学习一
2022-08-04 21:00:15 2.49MB 游戏
1
appinventer 软件开发 打地鼠游戏
2022-07-31 16:03:49 23KB appinventer 软件开发
1
android打地鼠游戏源码 学习点: 1、适应屏幕 2、切割图片 3、游戏动画
2022-06-23 09:11:37 4.66MB android 游戏 打地鼠 游戏源码
1
IOS应用源码之打地鼠游戏.zip
2022-06-18 19:07:35 324KB IOS应用源码
地鼠游戏源代码 素材.zip
2022-06-10 11:01:10 894KB 互联网
地鼠游戏源代码文档资料
2022-06-07 18:02:40 113KB 游戏 文档资料 源码软件
Java实现的打地鼠的游戏,采用多线程编程。欢迎下载互相讨论
2022-06-05 10:17:39 103KB Java 打地鼠
1
cocos2dx实现的一个小游戏源码 对cocos2dx的初学者来说会很有帮助
2022-06-04 11:07:06 6.87MB cocos2dx 游戏源码
1