kaplay-ui 0.3.1 → 0.5.0
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/index.js +3 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -2,14 +2,14 @@ import "kaplay/global";
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Adds a clickable button with custom text
|
|
5
|
+
* @param {string} txt - Button text to display
|
|
5
6
|
* @param {number} x - The x postion to set.
|
|
6
7
|
* @param {y} y - The y position to set.
|
|
7
|
-
* @param {string} txt - Button text to display
|
|
8
8
|
* @param {Function} [f] - Click event handler (default is () => {}))
|
|
9
9
|
* @param {boolean} [hover] - Add hover effect (default is true)
|
|
10
10
|
* @returns {GameObj}
|
|
11
11
|
*/
|
|
12
|
-
export const addTextButton = (x, y,
|
|
12
|
+
export const addTextButton = (txt, x, y, f = () => {}, hover = true) => {
|
|
13
13
|
const btn = add([
|
|
14
14
|
rect(240, 80, { radius: 8 }),
|
|
15
15
|
pos(x, y),
|
|
@@ -19,6 +19,7 @@ export const addTextButton = (x, y, txt, f = () => {}, hover = true) => {
|
|
|
19
19
|
color(255, 255, 255),
|
|
20
20
|
]);
|
|
21
21
|
|
|
22
|
+
// button text
|
|
22
23
|
btn.add([text(txt), anchor("center"), color(0, 0, 0)]);
|
|
23
24
|
|
|
24
25
|
btn.onClick(f);
|