diff --git a/react-native-game-engine.d.ts b/react-native-game-engine.d.ts index 08d5047..47b54f0 100644 --- a/react-native-game-engine.d.ts +++ b/react-native-game-engine.d.ts @@ -5,14 +5,15 @@ declare module "react-native-game-engine" { import * as React from "react"; import { StyleProp, ViewStyle, ScaledSize } from "react-native"; - interface DefaultRendererOptions { - state: any; - screen: ScaledSize; - } + export function DefaultRenderer(entities: any[], screen: ScaledSize, layout:LayoutRectangle): Component; - export function DefaultRenderer(defaultRendererOptions: DefaultRendererOptions): any; - - export class DefaultTimer {} + export class DefaultTimer { + loop: (time:number) => void; + start: () => void; + stop: () => void; + subscribe: (callback: () => void) => void; + unsubscribe: (callback: () => void) => void; + } interface TouchProcessorOptions { triggerPressEventBefore: number; @@ -38,20 +39,32 @@ declare module "react-native-game-engine" { } export type GameEngineSystem = (entities: any, update: GameEngineUpdateEventOptionType) => any; + + interface GameEngineEntity { + [key:string]: any; + renderer?: JSX.Element | React.ComponentClass; + } + type GameEngineEntities = Record; + export interface GameEngineProperties { systems?: any[]; entities?: {} | Promise; renderer?: any; touchProcessor?: any; - timer?: any; + timer?: DefaultTimer | any; running?: boolean; onEvent?: any; style?: StyleProp; children?: React.ReactNode; } - export class GameEngine extends React.Component {} + export class GameEngine extends React.Component { + dispatch: (event:any) => void; + start: () => void; + stop: () => void; + swap: ({}:any | Promise) => void | Promise + } export type TouchEventType = 'start' | 'end' | 'move' | 'press' | 'long-press'; @@ -86,13 +99,16 @@ declare module "react-native-game-engine" { export interface GameLoopProperties { touchProcessor?: any; - timer?: any; + timer?: DefaultTimer | any; running?: boolean; onUpdate?: (args: GameLoopUpdateEventOptionType) => void; style?: StyleProp; children?: React.ReactNode; } - export class GameLoop extends React.Component {} + export class GameLoop extends React.Component { + start: () => void; + stop: () => void; + } }