-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
16 additions
and
29 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import React from 'react'; | ||
import { TextureProps } from '../types/texture'; | ||
type Props = TextureProps; | ||
type Props = { | ||
name: string; | ||
}; | ||
export declare const Texture: React.FC<Props>; | ||
export {}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
import { TextureProps } from '../types/texture'; | ||
export declare function useTexture({ name, frame }: TextureProps): HTMLImageElement; | ||
export declare function useTexture(name: string): HTMLImageElement; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,12 @@ | ||
import { useMemo } from 'react'; | ||
import { useGame } from './use-game'; | ||
import { TextureProps } from '../types/texture'; | ||
|
||
export function useTexture({ name, frame }: TextureProps) { | ||
export function useTexture(name: string) { | ||
const game = useGame(); | ||
|
||
return useMemo(() => { | ||
const texture = game.textures.get(name); | ||
|
||
if (frame === undefined) { | ||
return texture.getSourceImage() as HTMLImageElement; | ||
} | ||
|
||
// @ts-ignore | ||
return texture.frames[frame].source.image as HTMLImageElement; | ||
}, [name, frame]); | ||
return texture.getSourceImage() as HTMLImageElement; | ||
}, [name]); | ||
} |
This file was deleted.
Oops, something went wrong.