redertween issue
Blitz3D Forums/Blitz3D Beginners Area/redertween issue
| ||
Hi all. Can anyone tell me how to implement a pause option while using rederwteening. I am using the tween code from the castle demo. When I pause the game its fine, but then on resume, the game logic cathes up to the amount of time paused. so if an entity were near the cam when paused.. and you paused for 10 seconds, on resume ti would be very far away. Could be a cool time warp effect, but not what im looking for right now. any advice, or code examples would be great, thanks |
| ||
BUMP |
| ||
without looking at the demo code: When game becomes paused - save/capture the current elapsed time. When game is unpaused - reset all the game time counters to the current system time, then add the time that you captured previously back to the new elapsed time. Make sense? |
| ||
Use this line when you press the 'unpause' key:time=MilliSecs()-periodIf you're using this in a function, then 'time' and 'period' will need to be global. |
| ||
ill give that a try [EDIT] got it.. using marks castle code for tweening i had to make these variables global. framePeriod frameTime then when the unpause was hit this had to be done framePeriod = 1000 / gameFPS frameTime = MilliSecs () - framePeriod that reset the logic counters so that it was fresh again and did not count any passed time. thanks |
| ||
Don't focus on Millisecs(), you are only worried about time elapsed since the last time you ran the game logic. something like the pseudo code below... when pause key is hit: elapsedTime = millisecs() - lastTime; store the elapsed time. (Last time is whenever you last did a 'tween' or checked the time.) when game is finally un-paused: lastTime = millisecs() - elapsedTime; set the current time count back by the amount you stored previously. |
| ||
got it above.. thanks for the help. much appreciated |