x


what does "for" mean

example for (var i = 0; i < Input.touchCount; ++i) { if (Input.GetTouch(i).phase == TouchPhase.Began) { Application.LoadLevel ("1");

what does for mean is it diffrent from if and where is it used

more ▼

asked Mar 29, 2012 at 08:13 PM

zeuo gravatar image

zeuo
463 187 140 159

(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

a for loop is a type of loop. that standard for loop sets variable i to 0, and its says as long as i is less than the user touch count, then add one to i. so its going to add 1 until i is equal to Input.touchCount.

more ▼

answered Mar 29, 2012 at 08:26 PM

Kag359six gravatar image

Kag359six
102 83 63 65

(comments are locked)
10|3000 characters needed characters left
more ▼

answered Mar 29, 2012 at 08:14 PM

by0log1c gravatar image

by0log1c
2.3k 19 19 35

(comments are locked)
10|3000 characters needed characters left

'For' is a type of loop. It allows you do one operation for some number of times. An example for loop looks like this :

   for(int i=0; i<10; i++){
     print i;
   }

First this sets i=0. Then it checks to see if i is less than 10 (i<10). If it is, it goes into the loop and prints out i. Then it increments i, by adding 1 to it ( i++) and checks to see if its less than 10 again. This keeps repeating until i is no longer less than 10.

more ▼

answered Mar 30, 2012 at 04:58 PM

perchik gravatar image

perchik
5.3k 11 909 36

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x97
x16
x8

asked: Mar 29, 2012 at 08:13 PM

Seen: 960 times

Last Updated: Mar 30, 2012 at 04:58 PM