Small Game, Big Lag

Show us your works in progress and request feedback

Post » Fri May 05, 2017 7:27 pm

Hello,

I've created a very simple game, though a bit of an update from the original Space Wars. I've tried to condense everything as much as possible, using families and such, but for the life of me, I can't figure out why certain objects on my 2nd Layout are constantly populating and slowing down the game. Below is a link to the .capx file, so hopefully that will help. Be warned, I have not yet finished cleaning things up, but at this point I don't feel like it should be as bad as it is.

Problem: Lag when playing the main game, layout 2

https://drive.google.com/file/d/0B13Pk_bMqZbDN2IwZjI5YlRnQWs/view?usp=sharing

This is my first game with Construct 2, so still a lot to learn. Any help would be greatly appreciate, thanks!
-Jamie
B
4
S
1
Posts: 2
Reputation: 306

Post » Fri May 05, 2017 10:11 pm

Events 4 & 10

Are you aware that the events run FPS times per second ? .... top-down.
One run trough the event sheet we call a 'tick'.

So your game starts. And in the first tick it creates those ships depending on player(1/2)choice.
The next tick, player(1/2)choice is unchanged. Hence, those events are still true. And it creates again those ships.
The next tick it creates more ships ...
And more .... and more ... and more ...

Run it in the debugger and watch the object count run out of control.

Easy solution ...
or 1/ add System > condition> 'Trigger once while true' to each event containing that 'player(1/2)choice = ?" conditoin.
or 2/ just change the value for player(1/2)choice to something like 9999 after it is for the first time used
or 3/ deactivate both groups after they ran once ... System > action > 'Set group active'
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Fri May 05, 2017 10:33 pm

Holy crap, I can't believe I didn't catch that!! THANK YOU SO MUCH!

Usually I choose solution #2, I'm in disbelief that I didn't do it this time around.


Thank you, thank you, thank you!
B
4
S
1
Posts: 2
Reputation: 306


Return to Works in Progress/Feedback Requests

Who is online

Users browsing this forum: No registered users and 5 guests