Search Unity

How to type [] by Boo

Discussion in 'Scripting' started by shinriyo_twitter, Sep 3, 2011.

  1. shinriyo_twitter

    shinriyo_twitter

    Joined:
    Aug 12, 2011
    Posts:
    328
    Hello I'm using Boo language.

    the Input.touches function is Touch[] type.

    but, I cannot type like this...

    Code (csharp):
    1. touches as Touch[] = Input.touches
    Code (csharp):
    1. touches[] as Touch = Input.touches
    only accept below writing like this??:eek:

    Code (csharp):
    1. for touch as Touch in Input.touches:
     
  2. VanJones

    VanJones

    Joined:
    May 1, 2011
    Posts:
    34
  3. shinriyo_twitter

    shinriyo_twitter

    Joined:
    Aug 12, 2011
    Posts:
    328
    Thanks.

    but..

    Code (csharp):
    1. touches as List = Input.touches
    BCE0022: Cannot convert '(UnityEngine.Touch)' to 'Boo.Lang.List'.

    what is wrong?
     
  4. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    touches is no list and you can not convert it to one this way, especially not to Boo list, if then you could convert it to System.Collection Lists or System.Collection.Generic List<> (unsure if boo eats generics)
     
  5. inn0vat3

    inn0vat3

    Joined:
    Jul 20, 2011
    Posts:
    13
    '(UnityEngine.Touch)' says that it's an array of UnityEngine.Touch's. Try

    Code (csharp):
    1. touches as (Touch) = Input.touches
    If that doesn't work, use this:

    Code (csharp):
    1. import System.Collections.Generic     //import this to use the generic list
    2. touches as List[of Touch] = List[of Touch]()     //this will declare touches as a generic list, then initialize it (The 'List[of Touch]()' part)
    3. for eachTouch as Touch in Input.touches:
    4. [INDENT]touches.Add(eachTouch)[/INDENT]
    That will iterate through Input.touches, and add each item as a Touch object to your touches list. This will DEFINITELY work.
     
  6. shinriyo_twitter

    shinriyo_twitter

    Joined:
    Aug 12, 2011
    Posts:
    328
    Thank you for replying.
    I converted Penelope sample.
    I did "touches as (Touch) = Input.touches"
    but it didn't work, so I'll try "System.Collections.Generic" edition latar
     
  7. flaminghairball

    flaminghairball

    Joined:
    Jun 12, 2008
    Posts:
    868
  8. shinriyo_twitter

    shinriyo_twitter

    Joined:
    Aug 12, 2011
    Posts:
    328