-
-
Save FlorianRappl/a1855c27c5bd8fd7a25c846e0614518b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "./Styles/tile.scss"; | |
import * as React from "react"; | |
import { Link } from "react-router-dom"; | |
import { PiletApi } from "sample-piral"; | |
import { appendMarioTo } from "./mario"; | |
export function setup(app: PiletApi) { | |
app.registerMenu(() => <Link to="/mario5">Mario 5</Link>); | |
app.registerTile( | |
() => ( | |
<Link to="/mario5" className="mario-tile"> | |
Mario5 | |
</Link> | |
), | |
{ | |
initialColumns: 2, | |
initialRows: 2 | |
} | |
); | |
app.registerPage("/mario5", () => { | |
const host = React.useRef(); | |
React.useEffect(() => { | |
const gamePromise = appendMarioTo(host.current, { | |
sound: true | |
}); | |
gamePromise.then(game => game.start()); | |
return () => gamePromise.then(game => game.pause()); | |
}); | |
return <div ref={host} />; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment