Variables initializing
1 post • Page 1 of 1
Variables initializing
I have found method to initialize local variables (Algodoo destroys them after exit).
Example:
So after load yourvar will be set to 0. With that you can use if and functions (they won't work if variable doesn't exist).
Useful example: laser timer.
Input: time, pause
Output: time
Example:
- Code: Select all
e.geom.ini = yourvar;
e.geom.yourvar = 0;
yourvar = ini;
So after load yourvar will be set to 0. With that you can use if and functions (they won't work if variable doesn't exist).
Useful example: laser timer.
Input: time, pause
Output: time
- Code: Select all
(e)=>{
e.geom.ini = timer;
e.geom.timer = 0; //initializes timer to 0 on scene start
timer = ini;
e.geom.ini = pause;
e.geom.pause = 0; //same here for pause switch
pause = ini;
pause == 1 ? {pause = 0} : {timer = timer + 1};
text = timer + ""
}
- krzat
- Posts: 11
- Joined: Fri Sep 04, 2009 3:36 pm
1 post • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 18 guests