espace

why this snippet don't work ?problem with parameter

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();
}

 

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.