How do I add delay to sprite following mouse cursor?

Get help using Construct 2

Post » Wed Jan 07, 2015 6:25 pm

nickdtsag wrote:Actually that works perfect for me. I can also adjust the speed by modifying the +2 or -2. And ofc set it to a var if i want and let the player set it.

Anyway, it works so its fine for me :)


Let me elaborate (now that I'm off-mobile) - the bad thing here is your use of a static "2" number - should your game stutter and a tick is lost the plane will still move just those 2 pixels - whether it's been 1/60th of a second or 1/6th.

So if you insist on doing it by hand - go ahead, but use dt - delta-time. It is the amount of time passed since last tick, assuming that one tick is 1. So if it was 1/60th of a second the value will be 1/60. Thus, if you wanted to moved 2px 60 times a second it is 120px/per second. So you should change that code to Y =Y + dt*120, for example.
B
19
S
6
G
7
Posts: 1,101
Reputation: 6,146

Post » Wed Jan 07, 2015 8:52 pm

@nickdtsag Then, do yourself a favor and use your solution together with dt or else it won't be framerate independent...
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
20
S
6
G
2
Posts: 621
Reputation: 3,494

Post » Wed Jan 07, 2015 9:48 pm

@someone thanks for the explanation, it was really helpfull :)
i switched to dt

Thanks @brunopalermo
I did myself the favor :p
B
9
S
1
Posts: 12
Reputation: 509

Previous

Return to How do I....?

Who is online

Users browsing this forum: dop2000, Yahoo [Bot] and 10 guests