Skip to content

Commit

Permalink
Fixed eslint issues, react configuration and added validations to cre…
Browse files Browse the repository at this point in the history
…ate the phaser game instance
  • Loading branch information
jdnichollsc committed May 1, 2020
1 parent 236d9c9 commit 421afdd
Show file tree
Hide file tree
Showing 44 changed files with 9,251 additions and 414 deletions.
16 changes: 16 additions & 0 deletions .eslintrc.json2
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"parserOptions": {
"project": "./tsconfig.json"
},
"extends": [
"plugin:@stencil/recommended"
],
"rules": {
"@stencil/strict-mutable": "off"
},
"settings": {
"react": {
"version": "16.7"
}
}
}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Looking for [Phaser Framework 3](https://github.com/photonstorm/phaser)? Check [

### Script tag

- Put a script tag similar to this `<script src='https://unpkg.com/@ion-phaser-ce/[email protected].2/dist/ionphaser.js'></script>` in the head of your index.html
- Put a script tag similar to this `<script src='https://unpkg.com/@ion-phaser-ce/[email protected].3/dist/ionphaser.js'></script>` in the head of your index.html
- Then you can use the element anywhere in your template, JSX, html etc

### Node Modules
Expand Down Expand Up @@ -193,7 +193,7 @@ When using a wrapper component, It's not necessary to access the reference direc
```tsx
import React, { Component } from 'react'
import Phaser from 'phaser-ce'
import { IonPhaser } from '@ion-phaser-ce/react'
import { IonPhaserCe } from '@ion-phaser-ce/react'

class App extends Component {
state = {
Expand All @@ -208,7 +208,7 @@ class App extends Component {
render() {
const { initialize, game } = this.state
return (
<IonPhaser game={game} initialize={initialize} />
<IonPhaserCe game={game} initialize={initialize} />
)
}
}
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions demo-react/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
7 changes: 6 additions & 1 deletion demo-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@
"private": true,
"dependencies": {
"@ion-phaser-ce/react": "file:../react",
"@types/jest": "^25.2.1",
"@types/node": "^13.13.4",
"@types/react": "^16.9.34",
"@types/react-dom": "^16.9.7",
"phaser-ce": "^2.13.3",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"react-scripts": "3.1.1"
"react-scripts": "^3.4.1",
"typescript": "^3.8.3"
},
"scripts": {
"start": "react-scripts start",
Expand Down
2 changes: 1 addition & 1 deletion demo-react/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ a.bttn-dark:focus {
}
}

.game {
ion-phaser-ce {
z-index: 1;
position: absolute;
width: 100%;
Expand Down
76 changes: 0 additions & 76 deletions demo-react/src/App.js

This file was deleted.

77 changes: 77 additions & 0 deletions demo-react/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import React, { Component } from 'react'
import { IonPhaserCe } from '@ion-phaser-ce/react'
import Phaser from 'phaser-ce'
import logo from './assets/logo.png'

import './App.css'

class MainState extends Phaser.State {
private helloWorld!: Phaser.Text

init() {
this.stage.backgroundColor = '#24252A';
}
create() {
this.helloWorld = this.game.add.text(
this.game.world.centerX,
this.game.world.centerY,
"Hello World", {
font: "40px Arial",
fill: "#ffffff"
}
);
this.helloWorld.anchor.set(0.5);
}
update() {
this.helloWorld.angle += 1;
}
}

const game: Phaser.IGameConfig = {
width: "100%",
height: "100%",
renderer: Phaser.AUTO,
state: MainState
}

class App extends Component {

state = {
initialize: false
}

initializeGame = () => {
this.setState({ initialize: true })
}

destroy = () => {
this.setState({ initialize: false })
}

render() {
const { initialize } = this.state
return (
<div className="App">
<header className="App-header">
{ initialize ? (
<>
<IonPhaserCe class="game" game={game} initialize={initialize} />
<div onClick={this.destroy} className="flex destroyButton">
<a href="#1" className="bttn">Destroy</a>
</div>
</>
) : (
<>
<img src={logo} className="App-logo" alt="logo" />
<div onClick={this.initializeGame} className="flex">
<a href="#1" className="bttn">Initialize</a>
</div>
</>
)}
</header>
</div>
);
}
}

export default App;
File renamed without changes.
1 change: 1 addition & 0 deletions demo-react/src/react-app-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="react-scripts" />
25 changes: 25 additions & 0 deletions demo-react/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react"
},
"include": [
"src"
]
}
1 change: 1 addition & 0 deletions demo-vue/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
Loading

0 comments on commit 421afdd

Please sign in to comment.