From b5b9bac2ff5a6b0cd9b512f9eab917a73b49f2ed Mon Sep 17 00:00:00 2001 From: kuangthree Date: Sat, 20 Apr 2024 15:06:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extension/coin/extension.js | 17 +++++++++++++---- layout/default/toast.css | 7 ++++--- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/extension/coin/extension.js b/extension/coin/extension.js index cf5aaa005..3e5e1293c 100644 --- a/extension/coin/extension.js +++ b/extension/coin/extension.js @@ -131,11 +131,20 @@ game.import("play", function () { } }, game: { - changeCoin: function (num,toast) { + changeCoin: function (num, toast, audio) { if (typeof num == "number" && ui.coin) { - if(num!=0 && toast!== false){ - game.playAudio('effect',num > 0?"coin":"coin_cost"); - ui.create.toast(`${num > 0 ? "获得":"花费"} ${num} 金币`); + if (num != 0 && toast !== false) { + ui.create.toast( + `${num > 0 ? "获得" : "花费"} ${Math.abs( + num + )} 金币` + ); + } + if (audio !== false) { + game.playAudio( + "effect", + num > 0 ? "coin" : "coin_cost" + ); } game.saveConfig("coin", lib.config.coin + num); var str; diff --git a/layout/default/toast.css b/layout/default/toast.css index b5486fb0b..b5f3d60bb 100644 --- a/layout/default/toast.css +++ b/layout/default/toast.css @@ -1,5 +1,5 @@ .toast-container { - display:block; + display: block; position: absolute; top: 15%; left: 50%; @@ -7,7 +7,6 @@ z-index: 9999; } - .toast { display: block; position: absolute; @@ -25,17 +24,19 @@ animation: fadeInOut 1500ms ease-in-out forwards; } - @keyframes fadeInOut { 0% { opacity: 0; } + 20% { opacity: 1; } + 80% { opacity: 1; } + 100% { opacity: 0; }