当前位置: 移动技术网 > IT编程>数据库>Redis > CocosCreator 监听龙骨绑定的帧事件

CocosCreator 监听龙骨绑定的帧事件

2020年07月17日  | 移动技术网IT编程  | 我要评论

简介

在龙骨中的Armature上绑定了一些帧事件,但是在CocosCreator中监听不到,看了官方的案例才明白是要用addEventListener监听Armature上的事件。

龙骨部分

这里是给龙骨添加帧事件
fall动画添加shooting事件
龙骨添加帧事件图

CocosCreator 项目设置

这里一定要把Animation Cache改为REALTIME才能监听到事件
组件详细设置

CocosCreator 添加监听代码

//拿到动画组件
this.animation = this.node.getComponentInChildren(dragonBones.ArmatureDisplay);
//循环播放某个动画
this.animation.playAnimation("fall", 0)
//拿到当前动画的armature
let arma = this.animation.armature();
//在armature上添加监听
arma.addEventListener(dragonBones.EventObject.FRAME_EVENT, (event) => {
		//TODO 这里写触发事件
		//event.name为事件名称
		console.log(event.name)
    }, this)

本文地址:https://blog.csdn.net/a71468293a/article/details/107356891

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网