Swapping the value of two numeric Attributes without a temp Attribute (try yourself before looking)

HopscotchHopscotch Member, PRO Posts: 2,782
edited January 2014 in Working with GS (Mac)
Hi again, another little snippet, especially helpful in GameSalad.

lets assume:
A=3 B=4
Usually when needing to swap the values of the two Attributes you would use a temporary Attribute:
temp=A A=B B=temp
To avoid cluttering Actors with temp Attributes you could do the following:
A=A+B (=7) B=A-B (7-4=3) A=A-B (7-3=4)
Voilà

This applies to numeric Attributes only though ;)

Comments

Sign In or Register to comment.