Last active
June 25, 2024 19:04
-
-
Save trezy/9c785337fd34c8137950910f283ec28f to your computer and use it in GitHub Desktop.
This file contains hidden or 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 { | |
Container, | |
Graphics, | |
} from 'pixi.js' | |
import { useExtend } from '@pixi/react' | |
export default function Enemy() { | |
useExtend({ | |
Container, | |
Graphics, | |
}) | |
return ( | |
<container> | |
<graphics draw={() => {}}> | |
</container> | |
) | |
} |
This file contains hidden or 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 { Application } from '@pixi/react' | |
import { lazy } from 'react' | |
const Enemy = lazy(() => import('./Enemy.js')) | |
const Player = lazy(() => import('./Player.js')) | |
export default function Game() { | |
return ( | |
<Application> | |
<Player /> | |
</Application> | |
) | |
} |
This file contains hidden or 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 { | |
Container, | |
Sprite, | |
Text, | |
} from 'pixi.js' | |
import { | |
useAsset, | |
useExtend, | |
} from '@pixi/react' | |
import { Suspense } from 'pixi.js' | |
export default function Player() { | |
useExtend({ | |
Container, | |
Sprite, | |
Text, | |
}) | |
const texture = useAsset({ | |
alias: 'player', | |
src: '/images/player.png', | |
}) | |
return ( | |
<container> | |
<Suspense fallback={<pixiText text={'Loading Player Sprite...'} />}> | |
<sprite texture={texture}> | |
</Suspense> | |
</container> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment