This repository was archived by the owner on Nov 12, 2024. It is now read-only.
call function from scene #446
Unanswered
jimmy008002
asked this question in
Q&A
Replies: 3 comments 1 reply
|
Actually, I am doing pose detection to control a game character, but putting everything on one web page include cam, game, detection is out of memory, I can fix it by setting the game size to 360 x 240, otherwise it will stop working, but i need to tackle the problem of controlling first. |
0 replies
Hi!! Welcome to kaboom. You can define your function in the top of your file kaboom();
function jump(player, JUMP_FORCE) {
if (player.isGrounded()) {
player.jump(JUMP_FORCE);
console.log("sdasdsdasdasdaaaaaaaaaaaaaaaaaaaaaaaa");
}
}
scene("start", () => {
const player = add([]);
jump(player);
});
scene("end", () => {
const player = add([]);
jump(player);
}); |
0 replies
|
Hi thank you so much for answering me! ` k.scene("game", () => { } jump();` now the problem is Cannot read properties of undefined (reading 'isGrounded') , I try to code in react, is it the reason I need to declare k in front of function? |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi, I am a beginner, I want to call the function outside the scene, is it possible?
For example,
k.scene("game", () => {
function jump() {
if (player.isGrounded()) {
player.jump(JUMP_FORCE);
console.log("sdasdsdasdasdaaaaaaaaaaaaaaaaaaaaaaaa")
}
}
I want to use jump() outside the scene to control the character in-game scene. How can I do it?
Thx
All reactions