how find solution

Get help using Construct 2

Post » Tue Jul 12, 2016 5:15 pm

https://dl.dropboxusercontent.com/u/44710358/cooldown.capx

Each enemy have variable called 'cooldown'
so when one enemy have cooldown=1 he should shoot every one second
but second enemy have 3 in cooldown but problem is because all enemies shoot at the same time

Maybe someone find a solution of this issue
Last edited by IGDev on Thu Jul 14, 2016 12:54 pm, edited 1 time in total.
B
24
S
7
Posts: 208
Reputation: 2,032

Post » Tue Jul 12, 2016 6:25 pm

Hi, so the problem is you aren't calling the code for each enemy, you are running it for both at the same time.

A way around this is to use a timer system for both enemies.

I added another variable to your enemies, called Timer. Timer is the part that changes, cooldown is simply the total cooldown for each enemy.

http://imgur.com/vjGziP1
B
13
S
6
Posts: 130
Reputation: 1,553

Post » Wed Jul 13, 2016 10:03 am

TMAJA thanks that worked :)
i have else problem

i add other variables
recoil (how fast enemy gun shoots)
burst (how many projectiles spawn when timer is 0)

Your timer for each enemy working
but recoil and burst is for all enemy at once

Please download again this same capx
Or someone else please
B
24
S
7
Posts: 208
Reputation: 2,032

Post » Wed Jul 13, 2016 4:39 pm

bump
B
24
S
7
Posts: 208
Reputation: 2,032

Post » Wed Jul 13, 2016 5:47 pm

IGDev wrote:TMAJA thanks that worked :)
i have else problem

i add other variables
recoil (how fast enemy gun shoots)
burst (how many projectiles spawn when timer is 0)

Your timer for each enemy working
but recoil and burst is for all enemy at once

Please download again this same capx
Or someone else please



Hi IGDev,

(Im on my mobile, cant load/open your project, so I hope I can help otherwise ;D )

you could try giving your enemy objects instance variables (or if you are working with families, give it to them), one for each. With a "for each" event you could check every enemy on your layout; reduce their individual variables by X every X triggers (or seconds, however you want it to be). A third condition inside your for-each loop could check if the variable is = X (compare instance variable) and then trigger other events (hope you got how I mean it :D ).

But be warned (if you have not had performance issues ever with C2), speaking about mobile games, "Every X seconds"-events *may* have a *huge* impact on cpu usage; if you plan having many enemies onscreen you possibly need an another solution for this (of course it depends on which device you have, its cpu, GHz, etc....).

Hope I helped. Regards
Proxy
B
24
S
14
G
9
Posts: 118
Reputation: 6,794


Return to How do I....?

Who is online

Users browsing this forum: Colludium, plinkie and 14 guests