what's the best way to optimize my events

Get help using Construct 2

Post » Fri Oct 10, 2014 9:45 pm

Hi
i kinda need help on how to optimize my events is there a better way to do this.

Thanks in advance
You do not have the required permissions to view the files attached to this post.
B
5
Posts: 17
Reputation: 259

Post » Fri Oct 10, 2014 10:05 pm

Optimization it's not something simple that can be done by removing or switching position of few events. It takes a lot of knowledge and experience to do that. And in most cases that means start all over again.

Looking at your capx I can see straight away that groups "Control 1..." to "Control 4..." are basically doing same thing. So here's your first thing that should be optimized.
Same goes to group "1", "2", "3" and "shooting", "shotgun2", "hk"

Do not repeat same event's every time you need to change few things, learn how to use functions - you could get your project from 100 event to probably 30-40.

You are still learning so don't be afraid to delete everything and start over from scratch using different methods.
ImageImageImageImage
B
157
S
66
G
42
Posts: 2,603
Reputation: 35,343

Post » Fri Oct 10, 2014 10:11 pm

about the controls each one contains different animation i ran into problem where the player collide with the pistol sprite than for example collide with the shotgun it will switch the weapon but the animation won't play that why i created a group for each weapon.
B
5
Posts: 17
Reputation: 259

Post » Fri Oct 10, 2014 10:31 pm

It's quite doable and pretty easy to do. But with your current setup I really advice you to start over and try different things, cause you start to have problems while adding new stuff to your projects :)
ImageImageImageImage
B
157
S
66
G
42
Posts: 2,603
Reputation: 35,343

Post » Sat Oct 11, 2014 9:52 am

Here I got it down from 96 to 37 but there is more that could be done. e.g. use a Family for the sprites, but I don't know if you have the full version. Also I use Functions a lot normally, but I didn't bother here.

Main things are:

1. Use arrays. Don't store values directly in your events. Then instead of If x is 1 do this else if x is 2 do that, etc. you can just have one line using x as an index to an array. In my file I've used multiple 1D arrays but you could use a 2D array as well. You could also load the values from JSON but I've just directly coded them on startup.

2. Look for repeating patterns in your events, and factor out the common stuff (then see point 1)

3. Use states (e.g 0=idle, 1=running) and act on the states, not directly on the player actions.
You do not have the required permissions to view the files attached to this post.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596


Return to How do I....?

Who is online

Users browsing this forum: KTML5 and 33 guests