From a317152e3f007d1520d81a0d5d827561ee1aee93 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 24 Nov 2023 22:28:29 -0600 Subject: [PATCH] Gameboy: tap the canvas to show/hide controls --- src/components/gameboy.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/components/gameboy.tsx b/src/components/gameboy.tsx index 2edb52065..d5e371e4d 100644 --- a/src/components/gameboy.tsx +++ b/src/components/gameboy.tsx @@ -24,6 +24,7 @@ const Gameboy: React.FC = ({ className, src, aspect = 'normal', onFocu const [paused, setPaused] = useState(false); const [muted, setMuted] = useState(true); const [fullscreen, setFullscreen] = useState(false); + const [showControls, setShowControls] = useState(true); async function init() { await WasmBoy.config(WasmBoyOptions, canvas.current!); @@ -49,6 +50,10 @@ const Gameboy: React.FC = ({ className, src, aspect = 'normal', onFocu setFullscreen(isFullscreen()); }, []); + const handleCanvasClick = useCallback(() => { + setShowControls(!showControls); + }, [showControls]); + const pause = async () => { await WasmBoy.pause(); setPaused(true); @@ -100,6 +105,7 @@ const Gameboy: React.FC = ({ className, src, aspect = 'normal', onFocu > = ({ className, src, aspect = 'normal', onFocu {...rest} /> -
+