>
> > hi,
> > i want to know how can i do pause game with very tick
> >
> > explain :
> >
> > iam using every tick ---- set x of background to background.X-5
> > but when i when to make pause (by set time scale to 0) the game is pause but the background stil move
> >
> > thanks
> >
>
> if instead of doing set x of background to background.X-5, you do set x of background to background.X-5*60*dt, not only the pause will work, but also if the framerate takes a hit during gameplay, the speed of the background in pixels/sec will not be affected.
>
FANSTASTIC , EXCELLENT
i dont know how to thank you
that work ... and the "X-5*60*dt" save performance and optimisation on iphone 4
now work fine and i solve my problem regarding iphone 4 (you remember in another post)
the "*60*dt" to make something vary is pretty handy (most C2's behaviors use it without telling it):
when you move something every tick by 5 pixels, it will move of 5 pixels every tick, if the game has slowdown, a tick isn't as fast as a framerate of 60 fps (where duration of a tick is 1/60 in that case).
dt is the time between each tick in seconds, for instance, if you add dt to a variable every tick, it'll increase of 1 each seconds, regardless of the framerate (exception if the framerate goes below 10 fps, but having 10 fps would imply more problems of course anyway)
adding 5*60*dt (=300*dt) means that at the end your tiled background each seconds will have travelled 300 pixels (5 pixels each 1/60 of seconds), regardless of the framerate
As I stated, with the execption of physics, every behavior I think uses that without you knowing it (this explains that they ask for a speed in px/s, and acceleration in px/s², and so on..).