rapid fire on touch release

Get help using Construct 2

Post » Sat Oct 07, 2017 6:48 pm

Hi Community,

I'm trying to create an event: - that shoots 10 balls when touch is released.... similar function to mobrix's brick breaker [url]'https://www.youtube.com/watch?v=ye49bSWL7Po'[/url]

functions:
Player holds down to move position. Angle stick follows touch. On release, it should spawn 10 balls (but this isn't happening)... one 1 is spawned, dispute System/Repeat assigned. Not sure if a while would suit this purpose, but I'll try searching on scirra for that one.

Here's my attempt http://robfreeman.co.uk/demo/
The project code is on the end.... pause the video to have a laugh.

I'd be grateful if any assistance.

Best Regards,
Rob
Last edited by RobertoFreemano on Sun Oct 08, 2017 7:23 am, edited 1 time in total.
B
5
S
2
Posts: 64
Reputation: 632

Post » Sat Oct 07, 2017 9:31 pm

Hey @RobertoFreemano!

Are you sure it's not spawning all ten balls one over the other. I would guess that's what's happening...

Check this capx: https://www.dropbox.com/s/ft721rvpbu8gw ... .capx?dl=0

Hope this helps. Cheers"
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
21
S
6
G
3
Posts: 664
Reputation: 3,855

Post » Sun Oct 08, 2017 2:39 am

@RobertoFreemano
Just to add to Bruno's answer - when you have a problem like this, start your game in Debug mode (Ctrl-F4). You would see that the number of ball instances is 10, as they are all spawned at the same moment.

Debug Mode is the one of the best features in C2 and everybody should use it! :)
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :)
B
17
S
9
G
71
Posts: 1,081
Reputation: 38,725

Post » Sun Oct 08, 2017 7:31 am

Wow Bruno, your example is awesome. I will try rebuild mine from scratch - based on your example.
...and thank you dop2000, I've never really used the Debug mode TBH. Are there any tutorials about this online?

Thanks again Guys!

Muchos appreciated ;)
Roberto
Last edited by RobertoFreemano on Sun Oct 08, 2017 7:56 am, edited 1 time in total.
B
5
S
2
Posts: 64
Reputation: 632

Post » Sun Oct 08, 2017 7:52 am

You don't need tutorials, just run the game in Debug Mode and explore all tabs, click everything and see what happens :)
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :)
B
17
S
9
G
71
Posts: 1,081
Reputation: 38,725

Post » Sun Oct 08, 2017 9:36 am

One more associated question, if I may?
Q: How would you restrict the player from firing again - once all 10 shots fired? I want to avoid being able to shoot again until all the balls are destroyed.
I've tried:
* spCannon.shotsfired > 10 -- spCannon Destroy
(This is where I get bamboozed) - spBullet.On destroyed -- system create spCannon.

Now I used Debug (thanks dop2000) and it shows creating spCannon per bullet destroy (ouch); which is 10 times (ouch)
B
5
S
2
Posts: 64
Reputation: 632

Post » Sun Oct 08, 2017 9:57 am

Do you always destroy a gun after firing one clip? :)

Just add another condition to your "On touch end" event:
System -> Compare two variables -> spBullet.Count=0

You need to make sure that all bullets get destroyed eventually. You can add "Destroy outside of layout" behavior.
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :)
B
17
S
9
G
71
Posts: 1,081
Reputation: 38,725

Post » Sun Oct 08, 2017 10:30 am

Awesome!!!

Thanks dop2000.
B
5
S
2
Posts: 64
Reputation: 632

Post » Sun Oct 08, 2017 3:15 pm

Also, in the capx I sent you can only fire again after the instance variable shooting is set to false. Currently, I was setting it to false when the last shot was fired. But you could just as easily set it to false only after the last shot is destroyed.
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
21
S
6
G
3
Posts: 664
Reputation: 3,855

Post » Sun Oct 08, 2017 3:45 pm

Thanks Bruno!

i have another issue (related to same project)... would it be rude to add to this or would you prefer i raise a new POST?
B
5
S
2
Posts: 64
Reputation: 632

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 34 guests