How do I create a spawn limit for a certain amount of time?

Just started using Construct 2? Post your questions here

Post » Sat Sep 23, 2017 8:01 am

I recently made the beginner game Pokémon themed with many more events. Whenever the right mouse button is held down, the player character shoots ultraballs INFINITELY. But I don't want it to be too over-powered, so I want to know how to make the character shoot 100 ultraballs, then have a timeout for 10 seconds so that the player can't shoot ultraballs, then after those 10 seconds, the player can shoot another 100 ultraballs and so on.

Also my audio won't work. I want to put music over it, so I put the .ogg file in the music folder, and then do the audio stuff in the event sheet. I preview it, but I cant hear anything. And no I do not have my speakers muted.

If anyone could help me out with these two things, that will be great!

:? :( :?:
B
9
Posts: 13
Reputation: 353

Post » Sat Sep 23, 2017 10:15 am

I assume you have something like this:
Mouse Right button is down : Player -> Spawn ultraball

You need to add instance variable to your player (say BallCounter) and Timer behavior.
Then do this:
Code: Select all
Mouse Right button is down
player.BallCounter<100
    Player -> Spawn ultraball
    Add 1 to player.BallCounter
    If player.BallCounter=100
          player start Timer "Cooldown" for 10 seconds (Once)


Player-> On Timer "Cooldown"
  player.BallCounter=0 


However you need to decide what happens if player shoots 80 ultraballs and then releases the button.
You may want to reset the counter immediately, or after a delay, or maybe decrease it by 10 every second or so.
Check out my awesome game Doptrix
B
17
S
9
G
30
Posts: 525
Reputation: 17,349

Post » Sat Sep 23, 2017 10:36 am

I don't really understand:

"player.BallCounter<100"

What do I do there?
B
9
Posts: 13
Reputation: 353

Post » Sat Sep 23, 2017 10:38 am

Wait hold on...

Do you mean I have to create another condition UNDER the Right mouse button down?
B
9
Posts: 13
Reputation: 353

Post » Sat Sep 23, 2017 10:47 am

No, sorry I don't really understand, I'm still quite new to Construct 2.
B
9
Posts: 13
Reputation: 353

Post » Sat Sep 23, 2017 10:57 am

Yes, exactly, another condition: player->Compare instance variable

Image
Check out my awesome game Doptrix
B
17
S
9
G
30
Posts: 525
Reputation: 17,349

Post » Sat Sep 23, 2017 9:24 pm

Ah, so now I get it.

'player.BallCounter' is the same as 'Player ---> BallCounter < 100'

Am I correct?

But thanks anyway, I'll give it a try!
B
9
Posts: 13
Reputation: 353

Post » Sat Sep 23, 2017 11:45 pm

I can't get it to work. I got the events set up, but I don't know how to stop the player from spawning more ultraballs when the limit has been reached.
B
9
Posts: 13
Reputation: 353

Post » Sun Sep 24, 2017 12:23 am

When the limit is reached, I want the game to ignore the right mouse button being clicked, but only for 10 seconds. How do I do that?
B
9
Posts: 13
Reputation: 353

Post » Sun Sep 24, 2017 2:57 am

Have you tried what I suggested in my first comment?
Could you post a screenshot of your code?
Or better yet, share the CAPX file.
Check out my awesome game Doptrix
B
17
S
9
G
30
Posts: 525
Reputation: 17,349

Next

Return to Beginner's Questions

Who is online

Users browsing this forum: mahdy and 1 guest