Skip to content

Commit fe41892

Browse files
committed
fix: tutorial progress display issue and images loading
1 parent d8cf729 commit fe41892

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/components/Tutorial.vue

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,30 @@ const show = ref(false)
66
const page = ref(0)
77
const total = 5
88
const props = defineProps<{ scene: Phaser.Scene }>()
9+
const images = ref<HTMLImageElement[]>([])
910
1011
onMounted(() => {
1112
const seen = localStorage.getItem("hasSeenTutorial")
1213
if (!seen) {
1314
show.value = true
1415
props.scene.input.enabled = false
16+
for (let i = 1; i <= total; i++) {
17+
const img = new Image()
18+
img.onload = () => {
19+
console.log(`Tutorial image ${i} loaded.`)
20+
}
21+
img.src = `/assets/tutorial-${i}.png`
22+
images.value.push(img)
23+
}
1524
}
1625
})
1726
1827
function nextPage() {
1928
if (page.value < total - 1) {
20-
page.value++
29+
const nextImage = images.value[page.value + 1]
30+
if (nextImage && nextImage.complete) {
31+
page.value++
32+
}
2133
} else {
2234
show.value = false
2335
props.scene.input.enabled = true
@@ -56,10 +68,8 @@ function nextPage() {
5668
}
5769
5870
.tutorial-progress {
59-
position: absolute;
60-
bottom: 16px;
61-
right: 16px;
6271
color: #fff;
6372
font-size: 16px;
73+
padding: 8px 12px;
6474
}
6575
</style>

0 commit comments

Comments
 (0)