How do I shoot every "variable-timer" once while true

Get help using Construct 2

Post » Mon Oct 24, 2016 10:28 am

I'm trying to make an static tower. The tower has a timer variable so my idea is to wait tower.timer seconds and then shoot.

I thought this was gonna be really easy but I'm getting problems. Either I get the tower shooting infinite bullets nonstop or just shotting the very first time without repeating the "wait loop".

I was going for something like:

For each tower > Wait tower.timer seconds > Spawn bullet. This has to happens only once while true, otherwise it will endlessly shoots bullets nonstop, but if I set once while true it will only do this once without repeating the timer countdown.

Any help?
B
14
S
5
Posts: 248
Reputation: 1,705

Post » Mon Oct 24, 2016 11:00 am

you might want to check the timer behavior for your towers rather than using the wait action.

https://www.scirra.com/manual/167/timer

I've made a quick exemple (I added a rotate effect with the rotate behavior just for fun) https://1drv.ms/u/s!AjkoCSebIn9Jiw8M5tPJp_4lOs7g
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Mon Oct 24, 2016 11:15 am

Aphrodite wrote:you might want to check the timer behavior for your towers rather than using the wait action.

https://www.scirra.com/manual/167/timer

I've made a quick exemple (I added a rotate effect with the rotate behavior just for fun) https://1drv.ms/u/s!AjkoCSebIn9Jiw8M5tPJp_4lOs7g


Nah, that doesn't do the trick. Each tower needs to have a different timer, that's why the variable.
B
14
S
5
Posts: 248
Reputation: 1,705

Post » Mon Oct 24, 2016 11:27 am

https://1drv.ms/u/s!AjkoCSebIn9JixGkmfKK87AMBeBp I changed it so it uses an instance variable (called fire_timer) to have the 2 towers shooting at a different pace.

maybe you can work out with that.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Mon Oct 24, 2016 12:23 pm

Aphrodite wrote:https://1drv.ms/u/s!AjkoCSebIn9JixGkmfKK87AMBeBp I changed it so it uses an instance variable (called fire_timer) to have the 2 towers shooting at a different pace.

maybe you can work out with that.


Yeah maybe I can work with that, will give it a try, thanks!

But still I would like to see an example without the timer behaviour..
B
14
S
5
Posts: 248
Reputation: 1,705

Post » Mon Oct 24, 2016 1:21 pm

Yeah, it doesnt work as I expected. I need more controll over it, something similar to what I'm doing, but I'm missing something to make it work.

This is quite close to what I'm aiming, the problem is, it only works for one tower. If I duplicate the sprite a few times it doesnt apply to every object, just to one.

Image
B
14
S
5
Posts: 248
Reputation: 1,705

Post » Mon Oct 24, 2016 1:55 pm

@Aphrodite 's example is exactly what you need. You should post an example of how it doesn't work for you.
ImageImageImage
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494

Post » Mon Oct 24, 2016 2:12 pm

blackhornet wrote:@Aphrodite 's example is exactly what you need. You should post an example of how it doesn't work for you.


It doesnt suit my purpose. Not saying it doesnt work, I'm saying it doesnt meet my expectations and controll over it.
B
14
S
5
Posts: 248
Reputation: 1,705

Post » Mon Oct 24, 2016 2:14 pm

Explain what's missing.
ImageImageImage
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494

Post » Mon Oct 24, 2016 3:25 pm

blackhornet wrote:Explain what's missing.


@BLACKHORNET

Here's the example given in this thread applied to my game.

Image

The numbers represent each Tower Timer. As you can see, it doesn't work as expected, since it doesnt follow the timer as it should and the most imporant stuff: It shoots random NON-TIMED bullets.

The real bullets should be the blue ones, since they're the ones which I set the animation too. The other ones are being created randomly I have no idea how, since the ones I'm creating are set to the blue animation.

Image

Also as you can see I set the degrees to 90, and it has been working in all my examples, but not on the example given. Not to mention the fact that using a behaviour to control something is not as effective as controlling it through events.

EDIT: Added For Each on the On Timer and it seems to fix some of the problems.

Furthermore. I think what I want to achieve is more like a Linear shooting. Something like a domino effect. How can I achieve that?
B
14
S
5
Posts: 248
Reputation: 1,705

Next

Return to How do I....?

Who is online

Users browsing this forum: Euduardo, Kin and 31 guests