# Function: init() (/jsdoc/pixi-vn/index/namespaces/Game/functions/init)



Call Signature [#call-signature]

\> **init**(`element`, `options`, `devtoolsOptions?`): `Promise`\<`void`>

Defined in: [src/index.ts:80](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/index.ts#L80)

Initialize the Game and PixiJS Application and the interface div.
This method should be called before any other method.

Parameters [#parameters]

element [#element]

`HTMLElement`

The html element where I will put the canvas. Example: document.body

options [#options]

`Partial`\<[`ApplicationOptions`](/jsdoc/pixi-vn/index/interfaces/ApplicationOptions)> & `object`

Equivalent to the options you can use when initializing a [PixiJS Application](https://pixijs.com/8.x/guides/components/application). Additionally, it supports the following options:

* `id`: The id of the canvas element.
* `navigate`: The route navigate function.
* `resizeMode`: The resize mode of the canvas.

devtoolsOptions? [#devtoolsoptions]

`Devtools`

Equivalent to the options you can use when initializing the [PixiJS Devtools](https://pixi-vn.com/start/canvas#use-pixijs-devtools-with-pixivn).

Returns [#returns]

`Promise`\<`void`>

Example [#example]

```typescript
const body = document.body
if (!body) {
    throw new Error('body element not found')
}
await Game.initialize(body, {
    navigate: (path) => {
        // navigate to the path
    },
    width: 1920,
    height: 1080,
    backgroundColor: "#303030"
    resizeMode: "contain"
})
```

Call Signature [#call-signature-1]

\> **init**(): `Promise`\<`void`>

Defined in: [src/index.ts:110](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/index.ts#L110)

Initialize only the GameUnifier, and not the PixiJS Application and the interface div.
This method can be used if you want to use only the GameUnifier features, such as save/load game,
without initializing the canvas.

Returns [#returns-1]

`Promise`\<`void`>
