Skip to content

Commit

Permalink
wait fo rthe scene to be Gameplay
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleguido committed Dec 21, 2023
1 parent bfc03eb commit e34d52e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/components/GameControls.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useSpring, a } from '@react-spring/web'
import { usePersistentStore } from '../store'
import { Gameplay, usePersistentStore, usePlayerStore } from '../store'
import './GameControls.css'
import { useEffect, useRef } from 'react'
import RoundButton from './RoundButton'
Expand All @@ -9,7 +9,7 @@ import { isMobile } from 'react-device-detect'
const GameControls = () => {
const hasSeenGameControlsTimerRef = useRef(null)
const isVisible = useRef(false)

const scene = usePlayerStore((state) => state.scene)
const [hasSeenGameControls, setHasSeenGameControls] = usePersistentStore((state) => [
state.hasSeenGameControls,
state.setHasSeenGameControls,
Expand All @@ -28,16 +28,16 @@ const GameControls = () => {
}))

useEffect(() => {
console.debug('[GameControls] hasSeenGameControls:', hasSeenGameControls)
if (!hasSeenGameControls) {
console.debug('[GameControls] hasSeenGameControls:', hasSeenGameControls,' scene: ', scene)
if (scene === Gameplay && !hasSeenGameControls) {
console.debug('[GameControls] show')

hasSeenGameControlsTimerRef.current = setTimeout(() => show(), 500)
}
return () => {
clearTimeout(hasSeenGameControlsTimerRef.current)
}
}, [hasSeenGameControls])
}, [scene, hasSeenGameControls])

const show = () => {
console.debug('[GameControls] show!!!')
Expand Down

0 comments on commit e34d52e

Please sign in to comment.