0.1.0-alpha.25 • Published 7 months ago

moroboxai-player-react v0.1.0-alpha.25

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

moroboxai-player-react

NPM version Node.js CI gitHub license Code Quality: Javascript Total Alerts

Embeddable player for running MoroboxAI games in React.

Installation

Using npm:

npm install moroboxai-player-react --save

Or:

git clone https://github.com/moroboxai/moroboxai-player-react.git
cd moroboxai-player-react
npm i
npm run build

Usage

Setup a simple React app with:

npx create-react-app my-app --template typescript

Add moroboxai-player-react as a dependency:

cd my-app
npm install moroboxai-player-react --save

Replace src/App.tsx with:

import "./App.css";
import Player from "moroboxai-player-react";

function App() {
    return (
        <div className="App">
            <header className="App-header">
                <Player
                    url="https://raw.githubusercontent.com/moroboxai/moroboxai-games/master/games/pong/"
                    splashart="https://raw.githubusercontent.com/moroboxai/moroboxai-games/master/games/pong/assets/splashart.png"
                    width={256}
                    height={256}
                />
            </header>
        </div>
    );
}

export default App;

Build and start a local server to see the result:

npm run build
npm run start

Props

NameTypeDefaultDescription
urlstringURL of the game
splashartstringURL of the placeholder image displayed before the game is loaded
widthnumberWidth of the div element
heightnumberHeight of the div element
resizablebooleantrueIf the game can resize the player
classNamestringClass name for the div container
autoPlaybooleanfalseAuto play the game after the player is initialized
speednumber1Speed of the game
onReadyfuncnoopSignature: function() => void Function called when the game is loaded and ready
onMountfuncnoopSignature: function(player: IPlayer) => void Function called when the component is mounted

License

This content is released under the MIT License.

0.1.0-alpha.18

8 months ago

0.1.0-alpha.17

8 months ago

0.1.0-alpha.19

8 months ago

0.1.0-alpha.21

7 months ago

0.1.0-alpha.20

8 months ago

0.1.0-alpha.23

7 months ago

0.1.0-alpha.22

7 months ago

0.1.0-alpha.25

7 months ago

0.1.0-alpha.24

7 months ago

0.1.0-alpha.10

8 months ago

0.1.0-alpha.12

8 months ago

0.1.0-alpha.11

8 months ago

0.1.0-alpha.14

8 months ago

0.1.0-alpha.13

8 months ago

0.1.0-alpha.16

8 months ago

0.1.0-alpha.15

8 months ago

0.1.0-alpha.8

9 months ago

0.1.0-alpha.5

2 years ago

0.1.0-alpha.4

2 years ago

0.1.0-alpha.7

2 years ago

0.1.0-alpha.6

2 years ago

0.1.0-alpha.3

2 years ago

0.1.0-alpha.2

2 years ago

0.1.0-alpha.1

2 years ago