[SOLVED]How do I check how fast something happened?

0 favourites
  • 15 posts
From the Asset Store
Full game Construct 2 and Construct 3 to post on Google Play
  • Hello World,

    So let's say I have a shake screen effect, and some "balls" for the player to destroy, and a "bullet" with which the player destroys them.(if anyone is curious how I plan to do the screen shake let me know)

    How do I tell C2 that I want the shake screen to be triggered only if the player destroys lets say 4 balls in lets say the same second? Or 6 balls in 1.5 seconds, or 9 in 2 seconds, or 5 in 1 second, etc.?

    Thank you.

  • Just thinking out loud..

    you could start a timer on the first ball destroyed, add to a global variable for each ball and check if on timer the variable is the amount you want, or if the amount is reached before the timer ends, maybe deducting from the variable on timer end..

    Well so many ideas made possible by the timer-behaviour, choose the one that suits you..

  • Ok LittleStain here is what I did following your suggestion. Does this look right to you? The event that says "Create object game over" is gonna be replaced by the actual shake, which I haven't created the events for yet, I just haven't gotten around to it yet. I'm thinking of putting those events in a function and then just replacing the "Create object game over" event to call on that function.

  • Ok LittleStain here is what I did following your suggestion. Does this look right to you? The event that says "Create object game over" is gonna be replaced by the actual shake, which I haven't created the events for yet, I just haven't gotten around to it yet. I'm thinking of putting those events in a function and then just replacing the "Create object game over" event to call on that function.

    This seems like what I was trying to suggest, does it get the results you were aiming for?

    Putting it in a function or temporarily enabling a group would be the way to go for the shake itself I guess..

  • Sadly no LittleStain , it doesn't work. I even made some modifications to make it more stable(at least that was their purpose) like changing the timer from the marbles(which get destroyed) to another object that is always there.

    Regardless the game over object never gets created... it's like the timer never completes....

    Any other ideas please? Anyone?

  • You can try

    define Global variable number Timer = 0

    define Global variable number Destroy = 0

    1.every tick -->> system add dt to Timer

    2. On Marbles destroy -->> system add 1 to Destroy

    -->> system set Timer = 0

    3. Destroy => 4 AND Timer1 < 1 -->> action you want

    -->> system set timer = 0

    -->> system set Destroy = 0

  • I guess making the TimerVariable=0 a subevent with the actions start timer and set TimerVariable to 1

    and adding an else add 1 to TimerVariable would solve it..

    Hahaha, I'm not really awake..

    Problem is you set the timer on an object and destroy it right after that..

    Destroying the object makes it so no actions can be applied and as such the timer is destroyed too..

    Which ensures ther can be no on timer action..

    Putting the timer on another object will take care of this..

  • If I really have to I'll try your way too MadSpy , but I want to stay away from everytick events as much as possible, so I'd like to try a little harder to make Stain's idea work.

    I guess you're still not awake LittleStain , like I said in the post above I already figured that part out and changed the timer to an object that never gets destroyed and is always present. I olso added the screen shake effect, here's how it looks now.

    Could you please redo the events in your C2 and show me where and what you would modify? As I'm not sure where to make the changes you suggested.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Like this works for me:

  • VIKINGS you're right, everytick increases CPU usage; LittleStain 's idea is much better (as usual)

    (I had not seen your picture , I was on the phone)

  • (as usual)

    Haha..

    "As usual" is a bit of an exaggeration, I still learn on here every day, but thanks..

  • Well, after a lot of tweaking to your latest suggestion LittleStain I finally got it to work!! Thank you!!

    And I olso realized what the problem was. It seems C2 is an idiot, what did you do Ashley , get him drunk? No, but seriously, it seems C2 does not know what = means....

    It doesn't matter what value I get C2 to check on in the third event 4, 3, 2, 1(YESS even 1 which we actually previously set it to in event nr.2!!!...) as long as I use =(equal to) C2 doesn't figure it out. However if I use >(greater than) well then it works....

    Extremely stupid in my opinion(guess now I have to go over all of my games and see if I used = anywhere else...) but at least I'm glad I got it to work. Thanks again Stain.

    And don't worry MadSpy , like Stain said, we're all here to learn. I don't think anyone here knows C2 inside out and 100% never needs any help.

  • Well, after a lot of tweaking to your latest suggestion LittleStain I finally got it to work!! Thank you!!

    And I olso realized what the problem was. It seems C2 is an idiot, what did you do Ashley , get him drunk? No, but seriously, it seems C2 does not know what = means....

    It doesn't matter what value I get C2 to check on in the third event 4, 3, 2, 1(YESS even 1 which we actually previously set it to in event nr.2!!!...) as long as I use =(equal to) C2 doesn't figure it out. However if I use >(greater than) well then it works....

    Extremely stupid in my opinion(guess now I have to go over all of my games and see if I used = anywhere else...) but at least I'm glad I got it to work. Thanks again Stain.

    And don't worry MadSpy , like Stain said, we're all here to learn. I don't think anyone here knows C2 inside out and 100% never needs any help.

    = (equal to) does work on my computer in the example from which I took the event-screenshot..

  • Well LittleStain maybe it's a bug that got fixed, I'm still runing build 200. I'm waiting on the next stable release to update....

  • = (equal to) does work works fine I never had any troubled since I brought C2

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)