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; }