facebook

one score point for each Touch

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #347471 Reply

    hardsofft
    Member

    I am wondering on how to add 1 score point for each touch in a systematic order.
    As for example if i have 3 balls numbered 1,2,3. so i need to start from 1 and then to 2,3. after touching on ball 3 then i need to touch in reverse manner like 3 to 2 and then to 1 and viceversa follows. so it needs to follow the same order…[i cannot start or touch any numbered ball as i wish]

    #347487 Reply

    Brandon
    Member

    You are going to need a variable with some checking (there are several ways to do this):

    //off the top of my head, untested, I think it should work….
    var myTouch = ‘0’;
    var myScore = 0;

    //function for ball one
    function ball1()
    {
    //check for first touch in order
    if (myTouch = ‘0’)
    {myTouch = ‘1’;myScore += 1;}
    //check for second touch in reverse order
    if (myTouch = ‘4’)
    {myTouch = ‘0’;myScore += 1;}
    }

    //function for ball two
    function ball2()
    {
    //check for first touch in order
    if (myTouch = ‘1’)
    {myTouch = ‘2’;myScore +=1;}
    //check for second touch in reverse order
    if (myTouch = ‘3’)
    {myTouch = ‘4’;myScore +=1;}
    }

    //function for ball three
    function ball3()
    {
    //check for first touch in order
    if (myTouch = ‘2’)
    {myTouch = ‘3’;myScore += 1;}
    }

    #347491 Reply

    hardsofft
    Member

    Hi cincy. thanq for the reply. i tried ur code in _custom.js and on ball click run javascript. sorry to say that nothing seem to working..any idea on whats going wrong with…

    #347492 Reply

    Brandon
    Member

    Oops, maybe bad code in the first one:
    //off the top of my head, untested, I think it should work….
    var myTouch = ‘0’;
    var myScore = 0;

    //function for ball one
    function ball1()
    {
    //check for first touch in order
    if (myTouch == ‘0’)
    {myTouch = ‘1’;myScore += 1;}
    //check for second touch in reverse order
    if (myTouch == ‘4’)
    {myTouch = ‘0’;myScore += 1;}
    }

    //function for ball two
    function ball2()
    {
    //check for first touch in order
    if (myTouch == ‘1’)
    {myTouch = ‘2’;myScore +=1;}
    //check for second touch in reverse order
    if (myTouch == ‘3’)
    {myTouch = ‘4’;myScore +=1;}
    }

    //function for ball three
    function ball3()
    {
    //check for first touch in order
    if (myTouch == ‘2’)
    {myTouch = ‘3’;myScore += 1;}
    }

    #347493 Reply

    hardsofft
    Member

    so cincy i need to insert the whole code in custom.js. is that fine or stil i need to do anything else

    #347495 Reply

    Brandon
    Member

    Yes, insert it into the custom JS file, then assign the ball items the corresponding function.
    If it still doesnt work let me know and I will see if I can do a sample mobi file.

    #347504 Reply

    hardsofft
    Member

    Hi cincy, i am sorry if i am disturbing you. i tried everything for a long time as you said but the score is not showing and nothing seems to happen with balls when touching in simulator…. i am attaching my zip file.

    Attachments:
    You must be logged in to view attached files.
    #347545 Reply

    Brandon
    Member

    I found your problem. In the buttons, instead of the entire function (which you have in the custom js file) you only need:

    ball1()

    This will activate the function in the custom js.

    Also, since you dont have anyway to actually see if the score is changing, you can place this inside the button ruy javascript;

    alert(myscore);

    So, in the button’s Run Javascript for the first one you will have:

    ball1();
    alert(myscore);

    Ball 2 will have:

    ball2();
    alert(myscore);

    etc…

Viewing 8 posts - 1 through 8 (of 8 total)
Reply To: one score point for each Touch

You must be logged in to post in the forum log in