格式化代码

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: {
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;

View File

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