import { useGame } from './useGame' ; import { useEffect } from 'react' ; /**
 * Runs the callback once every "step" event
 *
 * note: this is shorthand for useGameEvent("step", callback)
 */ export function useGameLoop ( onLoop ) { const game = useGame ( ) ; useEffect ( ( ) => { const callback = ( time , delta ) => { onLoop ( { delta , time } ) ; } ; game . events . on ( 'step' , callback ) ; return ( ) => { game . events . off ( 'step' , callback ) ; } ; } , [ onLoop ] ) ; }