How do I pause game with every tick ?

Get help using Construct 2

Post » Mon May 05, 2014 8:42 pm

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
B
46
S
16
G
8
Posts: 794
Reputation: 8,335

Post » Mon May 05, 2014 9:11 pm

Why not set a variable when you pause, then set a condition
if variable <> 1 ......do every tick
B
49
S
16
G
9
Posts: 1,098
Reputation: 11,222

Post » Mon May 05, 2014 9:11 pm

Put a condition that says if timescale not equal to 0 then set x background, etc....
B
49
S
12
G
10
Posts: 1,833
Reputation: 14,603

Post » Mon May 05, 2014 10:37 pm

matrixreal wrote: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.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Tue May 06, 2014 3:45 pm

Aphrodite wrote:
matrixreal wrote: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)
B
46
S
16
G
8
Posts: 794
Reputation: 8,335

Post » Tue May 06, 2014 4:02 pm

matrixreal wrote:
Aphrodite wrote:
matrixreal wrote: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..).
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Sat May 10, 2014 2:06 am

hi aphrodite
with your tricks i get excellent performance on iphone 4s
on iphone 4 , before i do your trick it was very very slow ... now with your trick it goes little faster than iphone 4S you understand me ?
B
46
S
16
G
8
Posts: 794
Reputation: 8,335


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 4 guests