Search Unity

Difference between webplayer and android in script

Discussion in 'Scripting' started by yls, Jun 15, 2014.

  1. yls

    yls

    Joined:
    Apr 13, 2012
    Posts:
    197
    Hi everyone,

    I'm requesting your help because i have a strange diffrence between the behaviour one script of my WebPlayer and my android.

    What i find strange is that it's not related to a graphical element but purely based on the script.

    You can find my demo here

    http://www.ylsphoto.fr/MathSolver/MathSolver.html

    It's a simple game which ask you to sort cards by swapping them
    when two cards are following one another they merge. For example when card 1 et card 2 are next on the other they will merge together and becoming one carde "1-2"


    Long story short : on the web player i got the intended behaviour. When you swap a merdged card (for example card "5-8") then became merdged the other way (ie card '8-5').

    but not on the android version ! where they stay "5-8"

    It's not a graphical elements but just a call in the script.

    Have you ever meet a situation where the same script doesn't work the same way on android and webplayer ?

    Regards
     
  2. yls

    yls

    Joined:
    Apr 13, 2012
    Posts:
    197
    Here is the code. It's look like the line "tiles.turn();" doesn't work only on the android device

    Any idea ?

    Code (JavaScript):
    1.     function rearrange( _r : int ) {
    2.    
    3.         var i : int;  
    4.      
    5.        //tilesNextTurn = new Tile[nbTile];
    6.        
    7.         for (i = 0; i < nbTile; i++) {
    8.             if (tiles[i].rang <= _r) {
    9.                 tiles[i].setRangDestination(_r - tiles[i].rang, nbTile);
    10.                 tiles[i].turn();
    11.                 tiles[i].triggerFlash = true;
    12.            
    13.             } else {
    14.                 tiles[i].setRangDestination(tiles[i].rang, nbTile);
    15.             }
    16.        
    17.         }
    18.  
    19.         endMoveTimer = Time.time + stepTimer;
    20.         isMoving = true;
    21.         isUpdated = false;
    22.        
    23.         nbTileStart = nbTile;
    24.         nbTileDestination = nbTile;
    25.        
    26.     }
    Code (JavaScript):
    1.  
    2.  
    3. class TuileGB extends  MonoBehaviour {
    4.  
    5.   var sens : int;
    6.  
    7. ...
    8.  
    9.   function turn() {
    10.   sens = - sens;
    11.   }
    12.  
    13. }
    14.  
     
  3. yls

    yls

    Joined:
    Apr 13, 2012
    Posts:
    197
    No idea ? Do you need additional info ?
     
  4. yls

    yls

    Joined:
    Apr 13, 2012
    Posts:
    197
    I have found the answer.. The function rearrange() was called if the user was touching the screen or clicking the screen.

    On the
    webplayer clicking only triggers the input.getmousebuttondown and not the Input.getTouch

    but on the android, clicking tiggers the input.getmousebuttondown and the Input.getTouch. Therefore calling the rearrange twice.