Is there a problem with "every x miliseconds"

For questions about using Classic.

Post » Sat Jul 16, 2011 1:22 pm

Hi all

I wanted to make smth like this.
-----------------------
If Player press "e" and Variable.e = 0 than
set speed = 500
Variable.e = 1
-----------------------
If variable.e = 1 than
every 4000 miliseconds
Variable.e = 0
-----------------------
If variable.e = 0 than
set speed = 200
-----------------------

Which I just wanted to make is 4 second boost.

First Problem : On first e press, Variable.e doesn't turn to 1. On second press it sometimes turns to 1, after that it returns to normal.
Second Problem : When it turns to 1, it should return to 0 exactly 4 seconds later. But it sometimes turns to 0 after 1 second or 2 seconds or even 0,5 second and sometimes after 4 seconds.

Whats going on ?

It's like, it doesn't start to count from 0 to 4000 when I press to e. It's like, it starts to count on layout start, and on e press It's a luck to catch it on 0 , sometimes you may catch it on 3500. So after 500 miliseconds, it reaches to 4000 , so condition becomes true and variable.e turns to 0.

I hope I could explain my problem.
B
7
S
1
G
1
Posts: 76
Reputation: 904

Post » Sat Jul 16, 2011 2:50 pm

It starts at the value you give it, just as you would if you were to count to yourself while looking at your watch. Like you wouldn't start at zero would you?
Try the function object's delay, or better yet use the timer behavior.
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Sat Jul 16, 2011 3:38 pm

Thank you very much for your help..

Actually I give a private variable to object. Than I used "every 1000 miliseconds" decrase that value 1, until it reaches to 0.

I don't know if it makes exact 4 seconds from 4 to 0 but I guess It's more accurate than my first try.
B
7
S
1
G
1
Posts: 76
Reputation: 904


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 6 guests