JsBattle React Component API
JsBattleBattlefield
For easier integration with ReactJs applications,
jsbattle-react package contains React component of JsBattle
Kind: global class
Properties
| Name | Type | Description |
|---|---|---|
| aiDefList | Array |
requred. array of AiDefinition objects that describes tanks that fight in the battlefield |
| width | Number |
width of battlefield canvas in pixels |
| height | Number |
height of battlefield canvas in pixels |
| battlefieldWidth | Number |
width of battlefield area |
| battlefieldHeight | Number |
height of battlefield area |
| renderer | String |
name of renderer to be used |
| rngSeed | Number |
rngSeed to be used for the simulation. Random seed will be used if not provided |
| timeLimit | Number |
duration of the battle. A battle without limit is started when not defined or set to zero |
| speed | Number |
speed multiplier of the battle. For example 2 means that the battle is playes at doubled speed |
| quality | Number |
Number between 0 and 1 that define rendering quality (if renderer supports it). String 'auto' can be also provided. In such case, quality will be automatialy adjusted to keep proper performance |
| teamMode | Boolean |
whether the battle is played in team mode or not |
| autoResize | Boolean |
if true, size of battlefield canvas will be automaticaly adjusted. Otherwise, fixed values from width and height properties will be used |
| modifier | function |
function applied before the battle that allow changes in the battlefield setup |
| onError | function |
callback for handling errors |
| onInit | function |
callback executed when battlefield is initialized (at the beginning or just after restart) |
| onReady | function |
callback executed when battle is ready to be started (e.g. after loading all assets) |
| onStart | function |
callback executed when battle is started |
| onRender | function |
callback executed on each rendering loop of the battle simulation |
| onFinish | function |
callback executed when battle is finished |
- JsBattleBattlefield
- .tankList ⇒
Array - .teamList ⇒
Array - .actualRendererQuality ⇒
Number - .stop() ⇒
undefined - .restart() ⇒
undefined - .addTank(aiDefinition) ⇒
undefined - .getSimulation() ⇒
Simulation
- .tankList ⇒
jsBattleBattlefield.tankList ⇒ Array
Kind: instance property of JsBattleBattlefield
Returns: Array - all tanks that were added to the battle
jsBattleBattlefield.teamList ⇒ Array
Kind: instance property of JsBattleBattlefield
Returns: Array - list of teams
jsBattleBattlefield.actualRendererQuality ⇒ Number
Kind: instance property of JsBattleBattlefield
Returns: Number - actual quality of renderer. If the quality was set as a number, that number will be returned. If the quality is set as 'auto', current numeric value of quality will be returned
jsBattleBattlefield.stop() ⇒ undefined
Stops battle simulation. It also stops rendering loop.
After stop, you cannot resume the battle. Use restart instead.
Kind: instance method of JsBattleBattlefield
jsBattleBattlefield.restart() ⇒ undefined
Restarts battle simulation.
Kind: instance method of JsBattleBattlefield
jsBattleBattlefield.addTank(aiDefinition) ⇒ undefined
Create a tank according to provided AiDefinition and adds it to the battle
Kind: instance method of JsBattleBattlefield
| Param | Type | Description |
|---|---|---|
| aiDefinition | AiDefinition |
defintion of tank AI script |
jsBattleBattlefield.getSimulation() ⇒ Simulation
Kind: instance method of JsBattleBattlefield
Returns: Simulation - JsBattle simulation object