-
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
25 changed files
with
162 additions
and
40 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
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,9 @@ | ||
import React from 'react'; | ||
/** | ||
* Use adaptive click event outside target element. | ||
* | ||
* @param ref - Target ref | ||
* @param callback - Event callback | ||
* @param depends - Callback dependencies | ||
*/ | ||
export declare function useClickOutside(ref: React.RefObject<HTMLElement>, callback: () => void, depends: any[]): void; |
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,10 @@ | ||
import React from 'react'; | ||
/** | ||
* Use adaptive click event on target element. | ||
* | ||
* @param ref - Target ref | ||
* @param type - Event type | ||
* @param callback - Event callback | ||
* @param depends - Callback dependencies | ||
*/ | ||
export declare function useClick(ref: React.RefObject<HTMLElement | Document>, type: 'up' | 'down', callback: (event: MouseEvent | TouchEvent) => void, depends: any[]): void; |
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,5 @@ | ||
import type Phaser from 'phaser'; | ||
/** | ||
* Get scene in which interface was created. | ||
*/ | ||
export declare function useCurrentScene<T extends Phaser.Scene>(): T; |
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,5 @@ | ||
import type Phaser from 'phaser'; | ||
/** | ||
* Get game instance. | ||
*/ | ||
export declare function useGame<T extends Phaser.Game>(): T; |
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,12 +1,16 @@ | ||
/// <reference types="react" /> | ||
/** | ||
* Using adaptive interaction flow. | ||
* Use adaptive interaction flow. | ||
* | ||
* Desktop: | ||
* --[ mouse enter (activate) ] --> [ click (use) ] --> [ mouse leave (disactivate) ] | ||
* | ||
* Mobile: | ||
* --[ click (activate) ] --> [ second click (use) ] --> [ auto disactivate ] | ||
* --[ click (activate) ] --> [ outside click (disactivate) ] | ||
* | ||
* @param ref - Target ref | ||
* @param callback - Event callback | ||
* @param depends - Callback dependencies | ||
*/ | ||
export declare function useInteraction(ref: React.RefObject<HTMLElement>, callback?: () => void, depends?: any[]): boolean; |
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 +1,6 @@ | ||
/** | ||
* Get actual media query result. | ||
* | ||
* @param query - Media query | ||
*/ | ||
export declare function useMatchMedia(query: string): any; |
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 +1,4 @@ | ||
/** | ||
* Check if platform is mobile. | ||
*/ | ||
export declare function useMobilePlatform(): boolean; |
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,3 +1,11 @@ | ||
/// <reference types="react" /> | ||
import { RelativePositionProps } from '../types/relative-position'; | ||
/** | ||
* Position relative to camera. | ||
* | ||
* @param props | ||
* @param props.x - World position X | ||
* @param props.y - World position Y | ||
* @param props.camera - Camera | ||
*/ | ||
export declare function useRelativePosition<T extends HTMLElement>({ x, y, camera, }: RelativePositionProps): import("react").MutableRefObject<T>; |
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,3 +1,12 @@ | ||
/// <reference types="react" /> | ||
import { RelativeScaleProps } from '../types/relative-scale'; | ||
/** | ||
* Scale relative to canvas size. | ||
* | ||
* @param props | ||
* @param props.target - Target value | ||
* @param props.min - Min scale | ||
* @param props.max - Max scale | ||
* @param props.round - Rounding | ||
*/ | ||
export declare function useRelativeScale<T extends HTMLElement>({ target, min, max, round, }: RelativeScaleProps): import("react").MutableRefObject<T>; |
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,9 @@ | ||
import type Phaser from 'phaser'; | ||
/** | ||
* Subscribe to scene update. | ||
* | ||
* @param scene - Scene | ||
* @param callback - Update callback | ||
* @param depends - Callback dependencies | ||
*/ | ||
export declare function useSceneUpdate(scene: Phaser.Scene, callback: () => void, depends: any[]): void; |
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,7 @@ | ||
import type Phaser from 'phaser'; | ||
/** | ||
* Get scene by key. | ||
* | ||
* @param key - Scene key | ||
*/ | ||
export declare function useScene<T extends Phaser.Scene>(key: string): T; |
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 +1,6 @@ | ||
export declare function useTexture(name: string): HTMLImageElement; | ||
/** | ||
* Get texture source image. | ||
* | ||
* @param key - Texture key | ||
*/ | ||
export declare function useTexture(key: string): HTMLImageElement; |
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
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
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
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,12 +1,17 @@ | ||
import { useMemo } from 'react'; | ||
import { useGame } from './use-game'; | ||
|
||
export function useTexture(name: string) { | ||
/** | ||
* Get texture source image. | ||
* | ||
* @param key - Texture key | ||
*/ | ||
export function useTexture(key: string) { | ||
const game = useGame(); | ||
|
||
return useMemo(() => { | ||
const texture = game.textures.get(name); | ||
const texture = game.textures.get(key); | ||
|
||
return texture.getSourceImage() as HTMLImageElement; | ||
}, [name]); | ||
}, [key]); | ||
} |