How do I not get my sprites overlapping when spawning

Get help using Construct 2

Post » Thu Jul 21, 2016 3:18 pm

i need help for this simple task cause i simply cant figure it out .

So the problem is that if i start spamming alot they will spawn inside each other and take abou 3 seconds to actually slowly not get stuck and i dont want that i would like them to just bounce out or something like that

i know it seems a bit confusing but here is my project hopefully you guys can help me :)

https://dl.dropboxusercontent.com/u/763 ... umber.capx
B
6
S
2
G
1
Posts: 3
Reputation: 483

Post » Thu Jul 21, 2016 5:36 pm

How to cage a trigger to once/tick.

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

Else there is virtual no limit to how many times a trigger can fire / tick ... & things gooing Async as hell.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Thu Jul 21, 2016 7:42 pm

99Instances2Go wrote:How to cage a trigger to once/tick.

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

Else there is virtual no limit to how many times a trigger can fire / tick ... & things gooing Async as hell.



could you explain how you did it i only get a few things but most im a noob with so i dont understand
B
6
S
2
G
1
Posts: 3
Reputation: 483

Post » Thu Jul 21, 2016 8:25 pm

The main problem you had is this:

A trigger happens !. It is not 'running top down' on its dedicated place in the events sheet. It runs when it is triggered by 'the happening' that it is designed to catch.

So, 'on key pressed' runs when the key is pressed. Instantly. When you press the key very fast, that event starts even running before the previous run of that event is completed.
Result: it runs several times in 1 tick, starting to pile up in that one event. Spawning under the same conditions. All on 1 position.

So, i figured, the best option is to sync the 'on key pressed' with the amount of ticks the system can swallow / sec. At a ratio 1 to 1.

To accomplish this, i use a global variable. I set it to 1 when the key is pressed. At the same time i only allow the 'on key pressed' run its actions when that global = 0. So, after the first press, the global = 1, and can not be executed again till that global = 0 again.

If i set that global = 0 in a new event. (in event 7), the 'on key pressed' can therefor only run its actions (and sub events) ONCE every tick. Now everything (creation, physics, position calculations) runs in SYNC.

This is ofcours not perfect, players on faster machine can spawn faster.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Fri Jul 22, 2016 5:33 pm

99Instances2Go wrote:The main problem you had is this:

A trigger happens !. It is not 'running top down' on its dedicated place in the events sheet. It runs when it is triggered by 'the happening' that it is designed to catch.

So, 'on key pressed' runs when the key is pressed. Instantly. When you press the key very fast, that event starts even running before the previous run of that event is completed.
Result: it runs several times in 1 tick, starting to pile up in that one event. Spawning under the same conditions. All on 1 position.

So, i figured, the best option is to sync the 'on key pressed' with the amount of ticks the system can swallow / sec. At a ratio 1 to 1.

To accomplish this, i use a global variable. I set it to 1 when the key is pressed. At the same time i only allow the 'on key pressed' run its actions when that global = 0. So, after the first press, the global = 1, and can not be executed again till that global = 0 again.

If i set that global = 0 in a new event. (in event 7), the 'on key pressed' can therefor only run its actions (and sub events) ONCE every tick. Now everything (creation, physics, position calculations) runs in SYNC.

This is ofcours not perfect, players on faster machine can spawn faster.


oh thats smart thanks for all the help now i get it :D
B
6
S
2
G
1
Posts: 3
Reputation: 483


Return to How do I....?

Who is online

Users browsing this forum: MiloMasson, Yahoo [Bot] and 36 guests