Skip to content

Commit

Permalink
Configuring files of global and phaser types
Browse files Browse the repository at this point in the history
  • Loading branch information
andremalveira committed Jun 16, 2023
1 parent e93638b commit ea2bc9e
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 31 deletions.
31 changes: 25 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
import Phaser from 'phaser';
import { config } from './config';

// plugins
// import 'phaser3-rex-plugins/.....'
import 'phaser/plugins/spine/dist/SpinePlugin'

// scenes
import Preload from './scenes/Preload';

new Phaser.Game(
Object.assign(config, {
scene: [Preload]
})
);
new Phaser.Game({
//SCENES
scene: [Preload],
//PLUGINS
plugins: {
scene: [
{ key: 'SpinePlugin', plugin: window.SpinePlugin, mapping: 'spine' }
]
},
type: Phaser.AUTO,
parent: 'db739594-062e-4b43-b0b5-3d3e3d17846e',
backgroundColor: '#222',
scale: {
width: 1920,
height: 1080,
mode: Phaser.Scale.FIT,
autoCenter: Phaser.Scale.CENTER_BOTH
},
});
26 changes: 3 additions & 23 deletions src/types/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,8 @@

//PHASER GLOBAL
declare global {
namespace Phaser {
interface Game {

}
interface Scene {

}
namespace GameObjects {
interface Text {

}
interface Image {

}
interface DOMElement {

}
}

interface Window {
SpinePlugin: any
}

}

export interface HexColor extends String { }
export {}

29 changes: 29 additions & 0 deletions src/types/phaser.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/// <reference path="../../node_modules/phaser/types/SpineGameObject.d.ts" />
/// <reference path="../../node_modules/phaser/types/SpinePlugin.d.ts" />
/// others type references here!

declare global {

namespace Phaser {
interface Game {

}
interface Scene {
teste:string
}
namespace GameObjects {
interface Text {

}
interface Image {

}
interface DOMElement {

}
}

}

}
export {}
1 change: 1 addition & 0 deletions src/types/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export interface HexColor extends String { }
2 changes: 1 addition & 1 deletion src/utils/phaser.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Scene } from "phaser";
import { HexColor } from "../types/global";
import { HexColor } from "../types/utils";

const get = (scene: Scene) => {
const center = () => {
Expand Down
7 changes: 6 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true
"noEmit": true,
"typeRoots": [
"src/types",
"node_modules/@types",
"node_module/phaser/types"
]
},
"include": ["./src/**/*", "src/types"]
}

0 comments on commit ea2bc9e

Please sign in to comment.