by johngalt00 » Mon Jul 22, 2013 8:09 am
I try to explain better with a sample.
I have an actor with the name "button" and an actor "scores".
If I click on the actor button I want to add 1 to point to the score.
So what I do is to add an Action "Mouse Button Down" at the "button" Actor, create there Script Editor and write the code:
loadVars("global","scores");
points = points + 1;
score.textNumber = points;
saveVars("global","scores");
This works and I have a correct value at the vars and also a right value at the screen which show me the right value at the score.textNumber.
Now I have 4 buttons and want to have done the same. So I write a global function
void writeButton() {
loadVars("global","scores");
points = points + 1;
score.textNumber = points;
saveVars("global","scores");
}
And at each button I create the Event "Mouse Button Down" at at each I write at the Script Editor this call:
writeButton();
Now I have the right value at the variable but the value on the screen show me the old value and not the new one. And I not understand why?
thx