[Solved] Improving and Optimizing Code

Get help using Construct 2

Post » Mon Oct 03, 2011 5:11 pm

Hello, Dcrew here! I have this:



The code makes it so that if the player is under a tree then the tree is half visible (50 opacity).. and if not then the tree is fully visible. Now as you see in that code I use a for each loop. and wondered if there was a way that uses less memory. it's not bad (it runs fine) but I'm guessing with my code that I used if I had like 50+ tree's then it would get laggy.. Is there another ray of hope? Or will an update make a better way?dcrew2011-10-03 19:06:53
B
17
S
4
G
5
Posts: 226
Reputation: 4,042

Post » Mon Oct 03, 2011 5:27 pm

Player overlapping tree = opacity 50
Player overlaping tree [negated] = opacity 100


???
B
18
S
4
G
1
Posts: 413
Reputation: 2,512

Post » Mon Oct 03, 2011 7:02 pm

Player overlapping tree = opacity 50
Player not overlapping tree = opacity 100

Yes, How is that humanly possibly difficult to understand? -.-

Edit: Oh I realise your suggesting code, I don't know if that would work because wouldn't you need to check each tree object with a For Each?

Edit 2: I'm a fruit!! It worked:

dcrew2011-10-03 19:05:17
B
17
S
4
G
5
Posts: 226
Reputation: 4,042


Return to How do I....?

Who is online

Users browsing this forum: Vegamon007 and 16 guests