mirror of
https://gitee.com/dgflash/oops-plugin-framework.git
synced 2026-05-13 09:14:50 +08:00
2. 存储模块性能提升,添加LRU缓存、批量操作支持,优化内存使用 3. 多语言模块性能与内存管理优化,组件查询性能提升 4. 时间模块类型安全与性能优化,使用泛型替代any,对象池机制减少内存分配 5. 事件系统修复双重注册、重复注册等严重问题,实现EventData对象池减少GC压力 6. RandomManager修复4个逻辑BUG,包括边界问题和越界问题 7. 音频模块内存与性能优化,避免重复加载,优化数据结构,添加完整清理机制 8. CCView与CCViewVM合并,支持按需启用MVVM 9. Collection模块优化,AsyncQueue添加队列容量限制,Collection查询性能提升 10. ECS系统全面优化,对象池复用减少内存分配,循环性能提升 11. 优化MVVM组件性能
83 lines
2.4 KiB
TypeScript
83 lines
2.4 KiB
TypeScript
/*
|
|
* @Author: dgflash
|
|
* @Date: 2023-01-30 14:00:41
|
|
* @LastEditors: dgflash
|
|
* @LastEditTime: 2023-02-09 10:54:28
|
|
*/
|
|
import type { EventTouch } from 'cc';
|
|
import { Animation, AnimationClip, Node, Sprite, _decorator } from 'cc';
|
|
import { oops } from '../../../core/Oops';
|
|
import ButtonSimple from './ButtonSimple';
|
|
|
|
const { ccclass, property, menu } = _decorator;
|
|
|
|
/** 有特效按钮 */
|
|
@ccclass('ButtonEffect')
|
|
@menu('OopsFramework/Button/ButtonEffect (有特效按钮)')
|
|
export default class ButtonEffect extends ButtonSimple {
|
|
@property({
|
|
tooltip: '是否开启'
|
|
})
|
|
disabledEffect = false;
|
|
|
|
private anim: Animation | null = null;
|
|
|
|
/** 按钮禁用效果 */
|
|
get grayscale(): boolean {
|
|
const sprite = this.node.getComponent(Sprite);
|
|
return sprite ? sprite.grayscale : false;
|
|
}
|
|
set grayscale(value: boolean) {
|
|
const sprite = this.node.getComponent(Sprite);
|
|
if (sprite) {
|
|
sprite.grayscale = value;
|
|
}
|
|
}
|
|
|
|
onLoad() {
|
|
this.anim = this.node.addComponent(Animation);
|
|
|
|
const ac_start = oops.res.get('common/anim/button_scale_start', AnimationClip);
|
|
const ac_end = oops.res.get('common/anim/button_scale_end', AnimationClip);
|
|
|
|
if (ac_start && ac_end && this.anim) {
|
|
this.anim.defaultClip = ac_start;
|
|
this.anim.createState(ac_start, ac_start.name);
|
|
this.anim.createState(ac_end, ac_end.name);
|
|
} else {
|
|
console.warn('[ButtonEffect] 动画资源加载失败或Animation组件创建失败');
|
|
}
|
|
|
|
this.node.on(Node.EventType.TOUCH_START, this.onTouchStart, this);
|
|
|
|
super.onLoad();
|
|
}
|
|
|
|
protected onTouchStart(event: EventTouch) {
|
|
if (!this.disabledEffect && this.anim) {
|
|
this.anim.play('button_scale_start');
|
|
}
|
|
}
|
|
|
|
protected onTouchEnd(event: EventTouch) {
|
|
if (!this.disabledEffect && this.anim) {
|
|
this.anim.play('button_scale_end');
|
|
}
|
|
|
|
super.onTouchEnd(event);
|
|
}
|
|
|
|
/** 组件销毁时的清理工作 */
|
|
onDestroy() {
|
|
this.node.off(Node.EventType.TOUCH_START, this.onTouchStart, this);
|
|
|
|
// 清理动画组件引用
|
|
if (this.anim) {
|
|
this.anim.destroy();
|
|
this.anim = null;
|
|
}
|
|
|
|
super.onDestroy();
|
|
}
|
|
}
|