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

Get help using Construct 2

Post » Sat Jul 11, 2015 10:33 am

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.
Last edited by VIKINGS on Sat Jul 11, 2015 7:00 pm, edited 1 time in total.
B
21
S
11
G
6
Posts: 414
Reputation: 5,335

Post » Sat Jul 11, 2015 10:39 am

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..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sat Jul 11, 2015 11:21 am

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.
Image
B
21
S
11
G
6
Posts: 414
Reputation: 5,335

Post » Sat Jul 11, 2015 12:40 pm

VIKINGS wrote: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.
Image


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..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sat Jul 11, 2015 4:28 pm

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?
B
21
S
11
G
6
Posts: 414
Reputation: 5,335

Post » Sat Jul 11, 2015 4:49 pm

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
Image Image
B
25
S
14
G
139
Posts: 877
Reputation: 72,512

Post » Sat Jul 11, 2015 4:57 pm

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..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sat Jul 11, 2015 5:38 pm

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.

Image
B
21
S
11
G
6
Posts: 414
Reputation: 5,335

Post » Sat Jul 11, 2015 5:45 pm

Like this works for me:

Image
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sat Jul 11, 2015 6:15 pm

@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)
Image Image
B
25
S
14
G
139
Posts: 877
Reputation: 72,512

Next

Return to How do I....?

Who is online

Users browsing this forum: Cubeeo and 24 guests