From f025b726de40ebce9f98834994eda656ef724b85 Mon Sep 17 00:00:00 2001 From: dgflash Date: Thu, 9 Feb 2023 10:55:50 +0800 Subject: [PATCH] =?UTF-8?q?ButtonEffect=E6=B7=BB=E5=8A=A0=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E7=A6=81=E7=94=A8=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/libs/gui/button/ButtonEffect.ts | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/assets/libs/gui/button/ButtonEffect.ts b/assets/libs/gui/button/ButtonEffect.ts index 162c895..e606f6c 100644 --- a/assets/libs/gui/button/ButtonEffect.ts +++ b/assets/libs/gui/button/ButtonEffect.ts @@ -1,4 +1,10 @@ -import { Animation, AnimationClip, EventTouch, _decorator } from "cc"; +/* + * @Author: dgflash + * @Date: 2023-01-30 14:00:41 + * @LastEditors: dgflash + * @LastEditTime: 2023-02-09 10:54:28 + */ +import { Animation, AnimationClip, EventTouch, Sprite, _decorator } from "cc"; import { oops } from "../../../core/Oops"; import ButtonSimple from "./ButtonSimple"; @@ -14,11 +20,21 @@ export default class ButtonEffect extends ButtonSimple { private anim!: Animation; + /** 按钮禁用效果 */ + get grayscale(): boolean { + return this.node.getComponent(Sprite)!.grayscale; + } + set grayscale(value: boolean) { + if (this.node.getComponent(Sprite)) { + this.node.getComponent(Sprite)!.grayscale = value; + } + } + onLoad() { this.anim = this.node.addComponent(Animation); - var ac_start = oops.res.get("common/anim/button_scale_start", AnimationClip)!; - var ac_end = oops.res.get("common/anim/button_scale_end", AnimationClip)!; + var ac_start: AnimationClip = oops.res.get("common/anim/button_scale_start", AnimationClip)!; + var ac_end: AnimationClip = oops.res.get("common/anim/button_scale_end", AnimationClip)!; this.anim.defaultClip = ac_start; this.anim.createState(ac_start, ac_start?.name); this.anim.createState(ac_end, ac_end?.name);