格式化代码

This commit is contained in:
kuangthree 2024-04-20 15:06:44 +08:00
parent 9a0d853afa
commit b5b9bac2ff
2 changed files with 17 additions and 7 deletions

View File

@ -131,11 +131,20 @@ game.import("play", function () {
} }
}, },
game: { game: {
changeCoin: function (num,toast) { changeCoin: function (num, toast, audio) {
if (typeof num == "number" && ui.coin) { if (typeof num == "number" && ui.coin) {
if (num != 0 && toast !== false) { if (num != 0 && toast !== false) {
game.playAudio('effect',num > 0?"coin":"coin_cost"); ui.create.toast(
ui.create.toast(`${num > 0 ? "获得":"花费"} ${num} 金币`); `${num > 0 ? "获得" : "花费"} ${Math.abs(
num
)} 金币`
);
}
if (audio !== false) {
game.playAudio(
"effect",
num > 0 ? "coin" : "coin_cost"
);
} }
game.saveConfig("coin", lib.config.coin + num); game.saveConfig("coin", lib.config.coin + num);
var str; var str;

View File

@ -7,7 +7,6 @@
z-index: 9999; z-index: 9999;
} }
.toast { .toast {
display: block; display: block;
position: absolute; position: absolute;
@ -25,17 +24,19 @@
animation: fadeInOut 1500ms ease-in-out forwards; animation: fadeInOut 1500ms ease-in-out forwards;
} }
@keyframes fadeInOut { @keyframes fadeInOut {
0% { 0% {
opacity: 0; opacity: 0;
} }
20% { 20% {
opacity: 1; opacity: 1;
} }
80% { 80% {
opacity: 1; opacity: 1;
} }
100% { 100% {
opacity: 0; opacity: 0;
} }