[SOLVED]How do I make a fastest lap's ghost in racing game?

Get help using Construct 2

Post » Mon Feb 15, 2016 2:07 pm

Hi to everybody!....and sorry for my poor english...
I apologize because there is anoter thread similar to this one, I know.... i've posted there too. But nobody can't (or want ;) ) help me, maybe because is an old post and a newer one have more visibilty. In that thread there is a suggestion about to make a ghost, but for a noob like me is hard to use only suggestions and trasform it in a capx. :oops:
I'm making a 2d racing game and i want to implement this feature. I've understanded (partially) the example and the use of array for this (thanks a lot!) and now i can record and playback only a single lap.
I'll try to explain better: when I finish a lap and my car is running another lap, I must stop to "record" to make possible to retrieve the values previously stored, so i can't record actual lap with a single array.
Partially I solved using two arrays, when one is recording the other one is "playing", but I believe it's not the right way.
Now my problem is that I am not able to playback the values stored in array only if current lap is faster than best lap.
I hope you can understand my problem, but mostly I hope you can help me! :D
Tanks!!!!
Last edited by pontolix on Wed Feb 17, 2016 12:14 am, edited 1 time in total.
B
7
S
1
Posts: 13
Reputation: 351

Post » Mon Feb 15, 2016 3:28 pm

not quite sure, But look up mario level record. I think that will have what you are looking for.
B
29
S
13
G
10
Posts: 355
Reputation: 8,337

Post » Mon Feb 15, 2016 6:08 pm

"Two arrays" is indeed the right way to do it. You also need to have variables to compare the best lap time vs the current lap time when you pass the finish line. If current time is less than the best time, then copy the "recording" array onto the "playback" array. An easy way to do it is to use PlaybackArray.Load(RecordArray.AsJSON), and then you can reset the RecordArray and start recording anew.
B
76
S
31
G
27
Posts: 1,015
Reputation: 20,790

Post » Tue Feb 16, 2016 2:37 pm

Thanks for the replies!
In the past I've tried to copy the values stored in recording array in a third array, than after comparing current lap time with best lap time, copying the values of third array in the playback one....but it seemed not working. But, at this point, surely for my ignorance in the use of arrays... :oops:
Now i'll give a try to the solution posted by Magistross(thank you!). :D
If i'll succed i'll publish on this post a guide for other noobs as me.
Thanks again to this beautiful comunity!!! :D
B
7
S
1
Posts: 13
Reputation: 351

Post » Tue Feb 16, 2016 11:04 pm

Message: pontolix can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
Finally I've managed to create a working ghost lap thanks to the suggestion of Magistross! :D
As I promised, I've created an example to share:

https://www.dropbox.com/s/sfg5mk5upvjvb ... .capx?dl=0

I don't know if the link it's working, because it's the first time i share a dropbox link from pc. Tell me if it's a bad link, than i'll provide.
Surely it's not the best way, but it works!
Thanks to all, but mostly to Magistross!
ciao a tutti!
B
7
S
1
Posts: 13
Reputation: 351

Post » Tue Feb 16, 2016 11:10 pm

Sorry, my reputation is under 250, so I can't share a link... :(
I don't know if in this way is working but I'll try.....

put www dropbox com before

/s/sfg5mk5upvjvbw5/ghost%20example.capx?dl=0

Sorry!
B
7
S
1
Posts: 13
Reputation: 351

Post » Wed Feb 17, 2016 2:19 am

It's working! Good job learning some new tricks. ;)
B
76
S
31
G
27
Posts: 1,015
Reputation: 20,790


Return to How do I....?

Who is online

Users browsing this forum: dop2000, hao102a2 and 26 guests