the Repeat condition

For questions about using Classic.

Post » Mon Dec 14, 2009 9:29 pm

I have used "repeat 2 times", but it keeps on creating the object, without stopping.
I would want to have:
- do something
- wait x seconds
- repeat this x times
So I used the "repeat"-condition. Good or bad use?

[code:1co6vdkk]System: Repeat 3 times
System: Every 1500 milliseconds
> System Create object Red1 on layer 1 at (905, 605)[/code:1co6vdkk]
Screenshot:
B
16
S
5
G
7
Posts: 599
Reputation: 5,000

Post » Mon Dec 14, 2009 9:34 pm

That's not right, 'every' doesn't make sense under a 'repeat' condition.

Try:
- do something
- use the function object to call a function after a delay
- in the function add a 'repeat 2 times' condition
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Mon Dec 14, 2009 10:50 pm

[quote="Ashley":l4sst9xs]
Try:
- do something
- use the function object to call a function after a delay
- in the function add a 'repeat 2 times' condition[/quote:l4sst9xs]

Doesn't work properly.
In the 3rd step, it does the repetition without delay.
I also tried to let the function call itself, after a delay, which didn't work.
I've tried the While-statement, but I can't get it work properly.

I think this is a very simple problem, but I have no idea.
I would like to have Construct do this:
- create sprite at 600, 900
- wait 1500ms
- repeat this process x times

This is something else I tried, that doesn't work:


It would be nice if Construct would have a "delay/wait"-action, instead of reaching out to functions, just to use the delay.

I've spent an hour doing what Construct is nt about: ignoring game design and trying to see how logics work :(
B
16
S
5
G
7
Posts: 599
Reputation: 5,000

Post » Mon Dec 14, 2009 10:59 pm

Use a timer? attach it to something hidden, that might work.
B
3
S
2
G
3
Posts: 628
Reputation: 2,531

Post » Mon Dec 14, 2009 11:13 pm

[quote="Lost my Keys":3byur4pd]Use a timer? attach it to something hidden, that might work.[/quote:3byur4pd]

By "timer", do you mean the object "profiler"? Or the System condition "compare time"?
I don't understand, I think.
B
16
S
5
G
7
Posts: 599
Reputation: 5,000

Post » Mon Dec 14, 2009 11:20 pm

[quote="rogerty":3ml7mnj0][quote="Lost my Keys":3ml7mnj0]Use a timer? attach it to something hidden, that might work.[/quote:3ml7mnj0]

By "timer", do you mean the object "profiler"? Or the System condition "compare time"?
I don't understand, I think.[/quote:3ml7mnj0]

The behavior timer. Make a sprite, add the timer behavior, create an event, lets say, start of layout. Select the sprite and then timer, create a timer and setup your options (it has repeat if you need it too) and then another event for on timer, and use that to create your object. It should work and do what you're wanting to do.
B
3
S
2
G
3
Posts: 628
Reputation: 2,531

Post » Mon Dec 14, 2009 11:46 pm

[quote="Lost my Keys":16ha0msf]
The behavior timer. Make a sprite, add the timer behavior, create an event, lets say, start of layout. Select the sprite and then timer, create a timer and setup your options (it has repeat if you need it too) and then another event for on timer, and use that to create your object. It should work and do what you're wanting to do.[/quote:16ha0msf]

I followed your instruction, but it gives an error. I did:
start layout: start timer "Timer" with length 1500, don't repeat, don't destroy.
(I've tried here also "repeat" and "destroy").
Event:
On timer "Timer"
> create sprite at x, y
B
16
S
5
G
7
Posts: 599
Reputation: 5,000

Post » Tue Dec 15, 2009 12:02 am

just do every 1500ms - create object at ...

you could limit the creation by count of object or by a global var,

every 1500ms
sprite.count < 10

- create object at ...

or
every 1500ms
global('count') > 0

create object at ..
substract 1 from global('count')
B
2
G
3
Posts: 72
Reputation: 994

Post » Tue Dec 15, 2009 12:05 am

[quote="rogerty":7stqs6vk][quote="Lost my Keys":7stqs6vk]
The behavior timer. Make a sprite, add the timer behavior, create an event, lets say, start of layout. Select the sprite and then timer, create a timer and setup your options (it has repeat if you need it too) and then another event for on timer, and use that to create your object. It should work and do what you're wanting to do.[/quote:7stqs6vk]

I followed your instruction, but it gives an error. I did:
start layout: start timer "Timer" with length 1500, don't repeat, don't destroy.
(I've tried here also "repeat" and "destroy").
Event:
On timer "Timer"
> create sprite at x, y[/quote:7stqs6vk]

Download: cap

Works for me, try that see if it works your end.
B
3
S
2
G
3
Posts: 628
Reputation: 2,531

Post » Tue Dec 15, 2009 12:13 am

Aphex, thanks a lot for your sollution, which was the simplicity I was looking for.
I didn't know sprite.count was possible...

Lost My Keys, thanks (even more) for replying thrice and supplying a .cap. Unfortunately I can't open the cap. Error message: abnormal program termination.
B
16
S
5
G
7
Posts: 599
Reputation: 5,000

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest