Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Last revision Both sides next revision
gdevelop:documentation:manual:pres_concepts [2020/05/31 11:36]
rapperdinesh [Variables]
gdevelop:documentation:manual:pres_concepts [2020/05/31 11:37]
rapperdinesh [Time elapsed since last frame (TimeDelta)]
Line 88: Line 88:
 ===== Time elapsed since last frame (TimeDelta) ===== ===== Time elapsed since last frame (TimeDelta) =====
  
-The game evaluates events and repaints the screen several times per second: we say that the game is //​refreshed//​. How often this happens depends on your computer resources: a slow computer can render 25 frames per second, a fast one 140. GDevelop can usually make sure that this value is the same on all computers, however the speed of some operations can change from computer to computer, for example mathematical operations and the rendering of movements.+The game evaluates events and repaints the screen several times per second: we say that the game is //​refreshed//​. How often this happens depends on your computer resources: a slow computer can render 25 frames per second, a fast one 140. GDevelop can usually make sure that this value is the same on all computers, howeverthe speed of some operations can change from computer to computer, for examplemathematical operations and the rendering of movements.
  
 To make the speed of changes constant, use the TimeDelta() expression, which returns the time in seconds since the last frame. To make the speed of changes constant, use the TimeDelta() expression, which returns the time in seconds since the last frame.
Line 99: Line 99:
 {{wiki:​pres_event6.png}} {{wiki:​pres_event6.png}}
  
-The first event is adding 20 to the variable every time the game is refreshed ( i.e. as much as possible ). It's **not correct** to use such event as the speed of the increase of the variable will not be the same from computer to computer: We cannot predict the value of the variable after 10 seconds for example.\\ +The first event is adding 20 to the variable every time the game is refreshed ( i.e. as much as possible ). It's **not correct** to use such event as the speed of the increase of the variable will not be the same from computer to computer: We cannot predict the value of the variable after 10 seconds for example.\\ 
-The second event is **correct and reliable** : The number 300 is multiplied by TimeDelta(). Thus, the variable will be increased at the same time on all computers. As  TimeDelta() returns a time in second, it allows you to quantify exactly the amount: In our case, the variable will grow at 300 unit/seconds. Thus, we can predicate that the life will increase by 3000 units in 10 seconds.+The second event is **correct and reliable**: The number 300 is multiplied by TimeDelta(). Thus, the variable will be increased at the same time on all computers. As  TimeDelta() returns a time in second, it allows you to quantify exactly the amount: In our case, the variable will grow at 300 units/seconds. Thus, we can predicate that life will increase by 3000 units in 10 seconds.
  
 Remember to use TimeDelta when you want to continually add some amount to a value.\\ Remember to use TimeDelta when you want to continually add some amount to a value.\\