kaplay-ui 0.20.0 β 0.20.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -167
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,207 +1,79 @@
|
|
|
1
|
-
|
|
2
|
-
<br>_π§ This package is a work in progress! π§_
|
|
3
|
-
_Expect breaking changes and incomplete features._
|
|
1
|
+
# KAPLAY UI
|
|
4
2
|
|
|
5
|
-
|
|
3
|
+
_A simple and customizable UI plugin library for building interfaces in https://kaplayjs.com/._
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
Kaplay UI provides a gameβoriented **UI plugin** designed specifically for KAPLAY.
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
It helps you build buttons, menus, controls, HUD elements, input fields, and moreβwithout reinventing the wheel.
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
> β οΈ **Note**
|
|
10
|
+
> The currently published stable version (`0.20.1`) is being replaced by a complete redesign.
|
|
11
|
+
> A new **v1** version is under active development and can be installed in prerelease form (see below).
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
- [Usage](#usage)
|
|
15
|
-
- [License](#license)
|
|
13
|
+
---
|
|
16
14
|
|
|
17
|
-
## Installation
|
|
15
|
+
## π¦ Installation
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
### Stable release
|
|
20
18
|
|
|
21
19
|
```bash
|
|
22
20
|
npm install kaplay-ui
|
|
23
21
|
```
|
|
24
22
|
|
|
25
|
-
|
|
23
|
+
### Prerelease (new v1 work)
|
|
26
24
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
All inputs are imported from the <code>/inputs</code> folder.
|
|
30
|
-
|
|
31
|
-
```javascript
|
|
32
|
-
import {} from "kaplay-ui/inputs";
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
#### Checkbox
|
|
36
|
-
|
|
37
|
-
To make a checkbox, one must use the exported <code>makeCheckbox()</code> function.
|
|
38
|
-
|
|
39
|
-
##### Example
|
|
40
|
-
|
|
41
|
-
An example usage of a checkbox.
|
|
42
|
-
|
|
43
|
-
```javascript
|
|
44
|
-
import kaplay from "kaplay";
|
|
45
|
-
import "kaplay/global";
|
|
46
|
-
|
|
47
|
-
import { makeCheckbox } from "kaplay-ui/inputs";
|
|
48
|
-
|
|
49
|
-
kaplay();
|
|
50
|
-
|
|
51
|
-
const checkBox = makeCheckbox();
|
|
52
|
-
|
|
53
|
-
add(checkBox);
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
##### State
|
|
57
|
-
|
|
58
|
-
A cehckbox has the following state:
|
|
59
|
-
|
|
60
|
-
| state | Type | Default | State change by |
|
|
61
|
-
| --------- | --------- | ------- | ----------------- |
|
|
62
|
-
| `checked` | `boolean` | false | Click on checkbox |
|
|
63
|
-
|
|
64
|
-
##### Parameters
|
|
65
|
-
|
|
66
|
-
A checkbox can take the following parameters:
|
|
67
|
-
|
|
68
|
-
| Parameter | Type | Default | Required | Description |
|
|
69
|
-
| --------- | -------- | ------- | -------- | ------------------- |
|
|
70
|
-
| `x` | `number` | 0 | β No | Checkbox x position |
|
|
71
|
-
| `y` | `number` | 0 | β No | Checkbox x position |
|
|
72
|
-
| `width` | `number` | 25 | β No | Checkbox width |
|
|
73
|
-
| `height` | `number` | 25 | β No | Checkbox height |
|
|
74
|
-
|
|
75
|
-
<br>
|
|
76
|
-
|
|
77
|
-
#### Switch
|
|
78
|
-
|
|
79
|
-
To make a text button, one must use the exported <code>makeSwitch()</code> function.
|
|
80
|
-
|
|
81
|
-
##### Example
|
|
82
|
-
|
|
83
|
-
An example usage of a text button.
|
|
84
|
-
|
|
85
|
-
```javascript
|
|
86
|
-
import kaplay from "kaplay";
|
|
87
|
-
import "kaplay/global";
|
|
88
|
-
|
|
89
|
-
import { makeSwitch } from "kaplay-ui/inputs";
|
|
90
|
-
|
|
91
|
-
kaplay();
|
|
92
|
-
|
|
93
|
-
const switchBtn = makeSwitch();
|
|
94
|
-
|
|
95
|
-
add(switchBtn);
|
|
25
|
+
```bash
|
|
26
|
+
npm install kaplay-ui@next
|
|
96
27
|
```
|
|
97
28
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
A cehckbox has the following state:
|
|
101
|
-
|
|
102
|
-
| state | Type | Default | State change by |
|
|
103
|
-
| ---------- | --------- | ------- | --------------- |
|
|
104
|
-
| `switched` | `boolean` | false | Click on switch |
|
|
105
|
-
|
|
106
|
-
##### Parameters
|
|
107
|
-
|
|
108
|
-
A switch can take the following parameters:
|
|
109
|
-
|
|
110
|
-
| Parameter | Type | Default | Required | Description |
|
|
111
|
-
| --------- | -------- | ------- | -------- | ----------------- |
|
|
112
|
-
| `x` | `number` | 0 | β No | Switch x position |
|
|
113
|
-
| `y` | `number` | 0 | β No | Switch x position |
|
|
114
|
-
| `width` | `number` | 50 | β No | Switch width |
|
|
115
|
-
| `height` | `number` | 25 | β No | Switch height |
|
|
116
|
-
|
|
117
|
-
#### Text Button
|
|
29
|
+
This gives you the latest `1.0.0βalpha.*` builds.
|
|
118
30
|
|
|
119
|
-
|
|
31
|
+
---
|
|
120
32
|
|
|
121
|
-
|
|
33
|
+
## π Usage
|
|
122
34
|
|
|
123
|
-
|
|
35
|
+
Kaplay UI exports a plugin for adding UI elements.
|
|
124
36
|
|
|
125
|
-
|
|
126
|
-
import kaplay from "kaplay";
|
|
127
|
-
import "kaplay/global";
|
|
37
|
+
The plugin is exported from the package root:
|
|
128
38
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
kaplay();
|
|
132
|
-
|
|
133
|
-
const txtBtn = makeTextButton("Start");
|
|
134
|
-
|
|
135
|
-
add(txtBtn);
|
|
39
|
+
```ts
|
|
40
|
+
import kaplayUI from "kaplay-ui";
|
|
136
41
|
```
|
|
137
42
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
A text button can take the following parameters:
|
|
141
|
-
|
|
142
|
-
| Parameter | Type | Default | Required | Description |
|
|
143
|
-
| ------------ | -------- | ------- | -------- | ---------------------------------- |
|
|
144
|
-
| `text` | `string` | N/A | β
Yes | The text to display on the button. |
|
|
145
|
-
| `x` | `number` | 0 | β No | Button x position |
|
|
146
|
-
| `y` | `number` | 0 | β No | Button y position |
|
|
147
|
-
| `width` | `number` | 100 | β No | Button width |
|
|
148
|
-
| `height` | `number` | 50 | β No | Button height |
|
|
149
|
-
| `btnRadius` | `number` | 8 | β No | Button radius |
|
|
150
|
-
| `btnOutline` | `number` | 1 | β No | Button outline |
|
|
151
|
-
| `txtSize` | `number` | 15 | β No | Text size |
|
|
152
|
-
|
|
153
|
-
<br>
|
|
43
|
+
---
|
|
154
44
|
|
|
155
|
-
|
|
45
|
+
## π§© Game Object (_**will evolve over time**_)
|
|
156
46
|
|
|
157
|
-
|
|
47
|
+
### **Switch**
|
|
158
48
|
|
|
159
|
-
|
|
49
|
+
### **Text Button**
|
|
160
50
|
|
|
161
|
-
|
|
51
|
+
Clickable text-based button:
|
|
162
52
|
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
import "kaplay/global";
|
|
166
|
-
|
|
167
|
-
import { makeToggle } from "kaplay-ui/inputs";
|
|
168
|
-
|
|
169
|
-
kaplay();
|
|
170
|
-
|
|
171
|
-
const toggle = makeToggle();
|
|
172
|
-
|
|
173
|
-
add(toggle);
|
|
53
|
+
```ts
|
|
54
|
+
const txtBtn = addTextButton("Play!", 200, 100);
|
|
174
55
|
```
|
|
175
56
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
A cehckbox has the following state:
|
|
57
|
+
---
|
|
179
58
|
|
|
180
|
-
|
|
181
|
-
| --------- | --------- | ------- | --------------- |
|
|
182
|
-
| `toggled` | `boolean` | false | Click on toggle |
|
|
59
|
+
## π£οΈ Roadmap
|
|
183
60
|
|
|
184
|
-
|
|
61
|
+
_to be added shortly .._
|
|
185
62
|
|
|
186
|
-
|
|
63
|
+
---
|
|
187
64
|
|
|
188
|
-
|
|
189
|
-
| --------- | -------- | ------- | -------- | ----------------- |
|
|
190
|
-
| `x` | `number` | 0 | β No | Toggle x position |
|
|
191
|
-
| `y` | `number` | 0 | β No | Toggle y position |
|
|
192
|
-
| `width` | `number` | 50 | β No | Toggle width |
|
|
193
|
-
| `height` | `number` | 25 | β No | Toggle height |
|
|
65
|
+
## π License
|
|
194
66
|
|
|
195
|
-
|
|
67
|
+
This project is licensed under the **MIT License**.
|
|
68
|
+
See the `LICENSE` file for details.
|
|
196
69
|
|
|
197
|
-
|
|
70
|
+
---
|
|
198
71
|
|
|
199
|
-
|
|
72
|
+
## π¬ Contact
|
|
200
73
|
|
|
201
|
-
|
|
74
|
+
Have questions or suggestions?
|
|
75
|
+
Open an issue on GitHub:
|
|
202
76
|
|
|
203
|
-
|
|
77
|
+
π <https://github.com/jbakchr/kaplay-ui>
|
|
204
78
|
|
|
205
|
-
Have questions or suggestions? Reach out via:
|
|
206
79
|
|
|
207
|
-
- GitHub Issues
|