Strange problem with increase an integer and switch
by Andrea Farid Marsili · in Torque Game Builder · 08/23/2010 (8:50 am) · 2 replies
I wrote this code to change the text of a textObject.
Calling the function I change the %n variable and with the switch I set the text.
This work for case 1 but not for case 2.
I try also with two if and with
This is my code.
Someone could tell me why the text object don't want to change his value?
Thanks to all
Calling the function I change the %n variable and with the switch I set the text.
This work for case 1 but not for case 2.
I try also with two if and with
$textField.text = %n;to see if the %n value change but the textObject display only 1.
This is my code.
Someone could tell me why the text object don't want to change his value?
function textClass::onLevelLoaded(%this, %scenegraph){
$textField = %this;
moveMap.bindCmd(keyboard, "space", "textFieldChange();", "");
}
function textFieldChange(){
%n++;
switch(%n){
case 1:
$textField.text = "ciao";
case 2:
$textField.text = "buongiorno";
}
}Thanks to all
Torque Owner Kevin James
%n++;//increase from 0 to 1
Even if you run textFieldChange a million times %n will never get beyond 1 because its a new variable every time.