x


How to return from the last case to the first

The whole thing is that i want to make a reload code for my ammo.

Example Code

   var ammo1:GUITexture;
    var ammo2:GUITexture;
    var ammo3:GUITexture;
    var AMMO = 3

    function FixedUpdate()
    {
    switch(AMMO)
    {
    case 1:
    guiTexture.texture = ammo1;
    break;
    }
    case 2:
    guiTexture.texture = ammo2;
    break;
    }
    case 3:
    guiTexture.texture = ammo3;
    break;

    case 4:
//return to case 1.
    break;
    }
    if(Input.GetButton("Fire1")
ScriptName.AMMO -= 1;
    }
more ▼

asked Dec 27 '10 at 11:46 AM

NickCh gravatar image

NickCh
170 6 8 14

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

1 answer: sort voted first

U could make the last case = the first one ie:

case 4:
 AMMO = 1;
break;

Or replace 4 with 0 since u run OUT of ammo.

more ▼

answered Dec 27 '10 at 03:54 PM

Jesus_Freak gravatar image

Jesus_Freak
1.2k 38 44 59

And replace 1 with 3

Dec 27 '10 at 03:56 PM Jesus_Freak

Yess thanks! Fool me i have tried it but instead of 1 i wrote 0...FOOL ME!!!

Dec 27 '10 at 04:47 PM NickCh
(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:

x3892
x3811
x494
x241
x79

asked: Dec 27 '10 at 11:46 AM

Seen: 869 times

Last Updated: Dec 27 '10 at 11:46 AM