Max expression need simplest sample

Get help using Construct 2

Post » Fri Sep 28, 2012 2:48 pm

Dear all

I am new in Construc2 and have very simple and dump question:

How do I using Max expression ....???

Problem is: I have many object and each object have it own IDD. How do I get object have highest IDD to pick and destroy..I don't want to using for - loop to save game performance...



Thank in advance
B
11
S
2
Posts: 73
Reputation: 1,438

Post » Fri Sep 28, 2012 5:25 pm

It's much simpler if you use a loop to find the instance with the highest value like in this post:
http://www.scirra.com/forum/how-to-pick-an-instance-by-higher-value_topic57344_post357107.html#357107

If you want to use the max() expression to do the same thing you will still need a loop.
[code]global number highest_idd

every tick
   set highest_idd to 0

for each sprite
   set highest_idd to max(highest_idd, sprite.idd)

sprite: idd equal to highest_idd
   destroy sprite[/code]
B
79
S
24
G
54
Posts: 4,746
Reputation: 40,755

Post » Fri Sep 28, 2012 10:28 pm

@R0J0hound

Thank to much for your reply. Actually, my game until now have more than 150 events and I really confuse about it's performance...??
Number of objects around 50 so and there are no way to avoid loop..??..:(

I got another question...What is faster...??? Using native system expression/event/condition or try to put some of them in my own plugin...??.
I want to put all of "family" object into MAX function and get max IDD like JavaScript..:D

Thank a lot for your help
B
11
S
2
Posts: 73
Reputation: 1,438


Return to How do I....?

Who is online

Users browsing this forum: fredriksthlm and 28 guests