π§ This package is a work in progress! π§
Expect breaking changes and incomplete features.
A simple and customizable component UI library for KAPLAY.
Kaplay UI is a component library designed specifically for KAPLAY. It will provide ready-made UI components to help you build better user interfaces for your KAPLAY games with minimal effort.
You can install Kaplay UI via npm:
npm install kaplay-uiAll inputs are imported from the /inputs folder.
import {} from "kaplay-ui/inputs";To make a checkbox, one must use the exported makeCheckbox() function.
An example usage of a checkbox.
import kaplay from "kaplay";
import "kaplay/global";
import { makeCheckbox } from "kaplay-ui/inputs";
kaplay();
const checkBox = makeCheckbox();
add(checkBox);A cehckbox has the following state:
| state | Type | Default | State change by |
|---|---|---|---|
checked |
boolean |
false | Click on checkbox |
A checkbox can take the following parameters:
| Parameter | Type | Default | Required | Description |
|---|---|---|---|---|
x |
number |
0 | β No | Checkbox x position |
y |
number |
0 | β No | Checkbox x position |
width |
number |
25 | β No | Checkbox width |
height |
number |
25 | β No | Checkbox height |
To make a text button, one must use the exported makeSwitch() function.
An example usage of a text button.
import kaplay from "kaplay";
import "kaplay/global";
import { makeSwitch } from "kaplay-ui/inputs";
kaplay();
const switchBtn = makeSwitch();
add(switchBtn);A cehckbox has the following state:
| state | Type | Default | State change by |
|---|---|---|---|
switched |
boolean |
false | Click on switch |
A switch can take the following parameters:
| Parameter | Type | Default | Required | Description |
|---|---|---|---|---|
x |
number |
0 | β No | Switch x position |
y |
number |
0 | β No | Switch x position |
width |
number |
50 | β No | Switch width |
height |
number |
25 | β No | Switch height |
To make a text button, one must use the exported makeTextButton() function.
An example usage of a text button.
import kaplay from "kaplay";
import "kaplay/global";
import { makeTextButton } from "kaplay-ui/inputs";
kaplay();
const txtBtn = makeTextButton("Start");
add(txtBtn);A text button can take the following parameters:
| Parameter | Type | Default | Required | Description |
|---|---|---|---|---|
text |
string |
N/A | β Yes | The text to display on the button. |
x |
number |
0 | β No | Button x position |
y |
number |
0 | β No | Button y position |
width |
number |
100 | β No | Button width |
height |
number |
50 | β No | Button height |
btnRadius |
number |
8 | β No | Button radius |
btnOutline |
number |
1 | β No | Button outline |
txtSize |
number |
15 | β No | Text size |
To make a toggle, one must use the exported makeTextInput() function.
An example usage of a toggle.
import kaplay from "kaplay";
import "kaplay/global";
import { makeTextInput } from "kaplay-ui/inputs";
kaplay();
const txtInput = makeTextInput();
add(txtInput);A text input can take the following parameters:
| Parameter | Type | Default | Required | Description |
|---|---|---|---|---|
x |
number |
0 | β No | x position |
y |
number |
0 | β No | y position |
width |
number |
400 | β No | width |
txtSize |
number |
15 | β No | Input text size |
pad |
number |
10 | β No | Padding |
hasFocus |
boolean |
true | β No | If text input has focus or not |
To make a toggle, one must use the exported makeToggle() function.
An example usage of a toggle.
import kaplay from "kaplay";
import "kaplay/global";
import { makeToggle } from "kaplay-ui/inputs";
kaplay();
const toggle = makeToggle();
add(toggle);A cehckbox has the following state:
| state | Type | Default | State change by |
|---|---|---|---|
toggled |
boolean |
false | Click on toggle |
A toggle can take the following parameters:
| Parameter | Type | Default | Required | Description |
|---|---|---|---|---|
x |
number |
0 | β No | Toggle x position |
y |
number |
0 | β No | Toggle y position |
width |
number |
50 | β No | Toggle width |
height |
number |
25 | β No | Toggle height |
This project is licensed under the MIT License - see the LICENSE file for details.
Have questions or suggestions? Reach out via:
- GitHub Issues