Jump to content

why this snippet don't work ?problem with parameter


espace
 Share

Recommended Posts

hi,

i don't understand why my function f.lock don't works. the first parameter (flag) is not recognized.

have you an advice about that ?

thanks :

 

f.test_game_over = () => {
    if (o.paper[0].flag && o.paper[1].flag) {
        console.log("game_over")
        //game over for all
    }
}

f.check_deep = (obj) => {
    if (f.checkOverlap(obj, o.sensor)) {
        //DONT works the first parameter is not obj.flag ...why ?
        f.lock(obj.flag, f.test_game_over)
       
//THIS WORKS BUT FOR ME IT's THE SAME ?
        //if (obj.flag == false) {
        //   obj.flag = true
        // f.test_game_over()
        //}
    }
}

f.lock = (flag, callback) => {
    if (flag == false) {
        flag = true;
    }
    callback();
}

 

Link to comment
Share on other sites

f.test_game_over = () => {
    if (o.paper[0].flag && o.paper[1].flag) {
        console.log("game_over")
        //game over for all
    }
}

f.check_deep = (obj) => {
    if (f.checkOverlap(obj, o.sensor)) {
        f.lock(obj, f.test_game_over)
    }
}

f.lock = (obj, callback) => {
    if (obj.flag == false) {
        obj.flag = true;
    callback();
    }
}

ok thanks

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...