Get help using Construct 2

### » Mon Jun 03, 2013 8:11 am

Hey you,

I have been looking the forums and tutorials but I haven't found anything that applies to me, just yet. Or maybe I don't fully understand. Anyways, I have a scrolling back that moves +6 pixels every tick.

I would like to do the same but with deltaTime. There doesn't seem to be an event for it. Any help?

Thank you,
Stephen
B
59
S
16
G
13
Posts: 826
Reputation: 17,910

### » Mon Jun 03, 2013 9:15 am

Deltatime is a constant... just reference it in your event by using Background.x=Background.x+6*dt (experiment here...)
B
33
S
6
G
7
Posts: 339
Reputation: 7,426

### » Mon Jun 03, 2013 10:02 am

[QUOTE=Ize] Deltatime is a constant... just reference it in your event by using Background.x=Background.x+6*dt (experiment here...)[/QUOTE]

Actually delta-time is not constant, it is time that has been elapsed since last tick occurred. That can vary. :)

When using delta-time, you really can't say 'move 6 pixels forward every tick' as you are just going against the whole principle of the thing. Instead, you can say that 'move 6 pixels in time frame of one second'.

DT creates framerate independence. Regardless of what FPS player has, the object will move those 6 pixels in time frame of one second if you are using dt. If you are not using it, player with lower FPS would move LESS than player with higher FPS, as he will have less ticks in a second.vee412013-06-03 10:02:37
B
24
S
9
G
7
Posts: 756
Reputation: 7,352

### » Mon Jun 03, 2013 1:07 pm

The tutorial delta-time and framerate independence covers exactly this.

Normally games run at 60 FPS. So if you move 6 pixels per tick, it's moving 6 x 60 = 360 pixels per second. However it will change if the framerate changes.

So to prevent it changing when the framerate changes, move it 360 * dt pixels per tick instead. Then it moves exactly the same speed as it did before at 60 FPS, but the actual speed does not change if the framerate changes.
Scirra Founder
B
414
S
245
G
92
Posts: 25,207
Reputation: 200,365

### » Mon Jun 03, 2013 5:33 pm

So, this is what I came up with @Ashley, @vee41, @Ize. I don't see a difference but I think that is mostly because I have a constant 60fps. I tried spawning 1000 objects and making them fly around but still no drop in fps. I will have to compile a mobile version and test it on my phone. Seeing as wifi preview doesn't work since I switched routers.

Anyways, here is what my events look like now. Is this correct?

Tekniko2013-06-03 17:34:16
B
59
S
16
G
13
Posts: 826
Reputation: 17,910