【cocos creator】点击屏幕粒子效果,不妨碍按钮点击[2022.07更新]
const { ccclass, property } = cc._decorator;
/*** 拖拽类,挂在要拖拽的节点上*/
@ccclass
export default class DragBasics extends cc.Component {@property(cc.Prefab)move_particle: cc.Prefab = null;@property(cc.Prefab)touch_particle: cc.Prefab = null;slideParticle: cc.ParticleSystem = null;private _isTouchMove: boolean;clickParticle: cc.ParticleSystem = null;private _isLoaderParticle: boolean = false;onLoad() {this.node.setSiblingIndex(this.node.parent.childrenCount - 1);this.node.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this);this.node.on(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this);this.node.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this);//@ts-ignorethis.node._touchListener.setSwallowTouches(false);//取消触摸节点的穿透事件//加载滑动的粒子// cc.loader.loadRes("prefabs/SlideParticle", cc.Prefab, (err, prefab) => {// var node = cc.instantiate(prefab);// node.parent = cc.find("Canvas").parent;// this.slideParticle = node.getComponent(cc.ParticleSystem);// this.slideParticle.node.active = false;// });var node = cc.instantiate(this.move_particle);node.parent = cc.find("Canvas").parent;this.slideParticle = node.getComponent(cc.ParticleSystem);this.slideParticle.node.active = false;//cc.game.removePersistRootNode(this.node);}onTouchStart(event) {var pos = event.touch.getLocation();if (this.slideParticle) {this.slideParticle.node.position = pos;this.slideParticle.resetSystem();this.slideParticle.duration = -1;//粒子一直发射}}onTouchMove(event) {this.onHideTouchParticle();//移动的时候不播放点击的粒子动画this._isTouchMove = true;if (this.slideParticle) {this.slideParticle.duration = -1;//粒子一直发射this.slideParticle.node.position = event.touch.getLocation();this.slideParticle.node.active = true;}}onTouchEnd(event) {if (this.slideParticle) {this.slideParticle.duration = 1;//粒子生命周期调为1s}var pos = event.touch.getLocation();if (!this._isTouchMove) this.playClickParticle(pos);this._isTouchMove = false;}/**播放点击的粒子动画 */playClickParticle(pos) {if (this.clickParticle) {this.clickParticle.duration = 0.3;//粒子生命周期调为1sthis.clickParticle.node.position = pos;this.clickParticle.node.active = true;this.clickParticle.resetSystem();} else {if (this._isLoaderParticle) {return;}this._isLoaderParticle = true;// cc.loader.loadRes("prefabs/ClickParticle", cc.Prefab, (err, prefab) => {// var node = cc.instantiate(prefab);// node.parent = cc.find("Canvas").parent;// this.clickParticle = node.getComponent(cc.ParticleSystem);// this.clickParticle.node.position = pos;// this.clickParticle.resetSystem();// });var node = cc.instantiate(this.touch_particle);node.parent = cc.find("Canvas").parent;this.clickParticle = node.getComponent(cc.ParticleSystem);this.clickParticle.node.position = pos;this.clickParticle.resetSystem();this.clickParticle.duration = 0.3;//粒子生命周期调为1s}if (this.slideParticle) {this.slideParticle.node.active = false;}}/**隐藏点击的粒子动画 */onHideTouchParticle() {if (this.clickParticle) {this.clickParticle.node.active = false;}}
}
【cocos creator】点击屏幕粒子效果,不妨碍按钮点击[2022.07更新]相关推荐
- cocos creator 实现手机震动的效果(最全说明)
cocos creator 实现手机震动的效果(最全说明) 之前在做creator时,需要打包调用安卓震动,看了许多其他博客的方法,虽然意思说明了但是东西不全,因此也花了不少时间.然后自己总结了套最全 ...
- js实现屏幕粒子效果
js实现屏幕粒子效果 效果如下: vue如下: <template><canvas id="theCanvas"></canvas> </ ...
- 《Cocos Creator游戏实战》实现下拉框按钮ComboBox控件
实现下拉框按钮ComboBox控件 创建节点 编写脚本 该功能已收录在Many Widgets插件中,使用Cocos Creator 3.x版本的小伙伴可以用该插件快速生成下拉框ComboBox控件. ...
- 用 Cocos Creator 模拟书本翻页效果
本篇文章作者:乐府-贝塔 乐府-贝塔:乐府前端核心开发,从事游戏开发多年,从 Cocos2d-x 做到 Cocos Creator,擅长渲染技术的相关优化.多年的前端开发经验激发了对技术研究的深厚兴趣 ...
- Cocos Creator 的实现拖尾效果
在游戏中,有时会需要在某个游戏对象上加上移动后的轨迹若隐若现的效果.使得游戏的效果较好,比如游戏大招,刀光,法术,流星划痕之类. Cocos Creator提供了一种内置的拖尾渐隐效果的实现方法:组件 ...
- Cocos Creator下JavaScript模拟射箭效果,附代码
获取代码 关注微信公众号,发送[射箭]获取代码 效果预览 操作方法 点击屏幕,屏幕出现起始位置标志的圆点,不松开手指,滑动屏幕,控制力度和方向,移动距离越大,弓箭拉伸效果越大,松开以后,箭将沿着结束点 ...
- cocos creator 实现手机震动的效果
目前需要wx, android,ios三个平台发布 android 平台下: 将项目打包发布形成build文件夹,用Android studio 打开如下目录:***\build\jsb-link\f ...
- 测试点击屏幕次数的软件_闪电点击app下载-闪电自动点击 安卓版v1.3.2
闪电自动点击app是一款帮助用户自动完成点击任务的应用,闪电自动点击器软件上一键设置即可自动帮你玩游戏,连续完成点击得奖励,闪电点击app内置脚本运行非常稳定. 软件介绍 闪电自动点击(快点神器)是一 ...
- java的按钮点击事件_[转载]java处理按钮点击事件
不同的事件源可以产生不同类别的事件.例如,按钮可以发送一个ActionEvent对象,而窗口可以发送WindowEvent对象. AWT时间处理机制的概要: 1.监听器对象是一个实现了特定监听器接口( ...
最新文章
- Exchange 2013 合规性管理之日记规则
- 关于wpf窗体中Allowtransparent和WindowsFormsHost的纠纷
- VSCode 阅读 Linux 代码怎么才不卡顿?这样做才能快的飞起!
- 使用dom breakpoint找到修改属性的javascript代码
- 程序员养生攻略,你值得拥有
- 第一批升级鸿蒙系统,鸿蒙系统公开了第一批升级名单,果粉认为不地道
- 几种常见软件过程模型的比较
- 当create table as select 遇上大数据
- shell编程入门步步高(七、流程控制)
- html分页器的实现原理,Django之分页器
- 9 个小技巧让你的 if else 看起来更优雅!
- 链表+启发式合并(bzoj 1483: [HNOI2009]梦幻布丁)
- javascript客户端验证函数大全
- ffmpeg php 使用教程_php的ffmpeg - CSDN博客
- 便携主机推荐——ATX电源篇
- Sonic 云真机测试平台1.3.2-release版本搭建
- php cpu飙高,PHP-FPM进程CPU 飙高的原因及解决方案
- css+js实现自动伸缩导航栏
- 诛仙3 私服架设 仿官网
- 独立性与互不相容的区别
热门文章
- Linux IP不为空 脚本,Linux系统防CC攻击自动拉黑IPShell脚本
- 【VC皮肤】破解版skin++皮肤库使用
- 老毛桃制作U盘启动盘
- 解决EOS报错Error in nodeos: corrupted size的问题
- URL及URL encoding 简述
- 小米note3 android 8,小米 Mi Note 3(小米Note3 安卓8.1)获取Root权限服务含精简系统方案...
- 海店湾:食用油中“物理压榨”和“化学浸出”有什么不同?
- 苹果6s上市时间_苹果6S目前和哪个档次的安卓手机一样?答案秒杀众多品牌机...
- 中国科学院大学发布人才召集令!科研启动经费最高700万!
- CAD梦想画图中“全图白色显示与彩色显示”如何设置