Compare age?

New releases and general discussions.

Post » Thu Oct 02, 2008 11:23 am

Comparing the age of a sprite would be a useful feature, and i know mmf keeps age stored, so i assume construct does this 2?, it would be usefull to have a compare age feature so we could lets say make a for each ordered by their ages, if you needed something along that lines it would be nice 2 have. all its doing is storing and comparing the order they were created, not how long theyve existed btw.
B
52
S
7
G
6
Posts: 1,945
Reputation: 7,610

Post » Thu Oct 02, 2008 11:49 am

Create private Variable to "Sprite.UID" and then use event "Pick with lowest Variable". Remember to use "For each" event to set up the UID.
If you want to pick the younger use "highest".
B
4
S
2
G
4
Posts: 719
Reputation: 2,938

Post » Thu Oct 02, 2008 12:15 pm

Managing object's age can be done by one event (PV "age" -> add to value -> timedelta). ActionsConditionsExpressions shouldn't be filled with unnecessary entries.
B
6
S
3
G
6
Posts: 219
Reputation: 3,013

Post » Thu Oct 02, 2008 12:23 pm

[quote="BROO":3bt8b2ef]Managing object's age can be done by one event (PV "age" -> add to value -> timedelta). ActionsConditionsExpressions shouldn't be filled with unnecessary entries.[/quote:3bt8b2ef]

Ummmm timedelta is not changing untill the FPS are changed. Soo you meant "TickCount" or "Timer"?
B
4
S
2
G
4
Posts: 719
Reputation: 2,938

Post » Thu Oct 02, 2008 12:28 pm

[quote="Doppel":1lh1njss][quote="BROO":1lh1njss]Managing object's age can be done by one event (PV "age" -> add to value -> timedelta). ActionsConditionsExpressions shouldn't be filled with unnecessary entries.[/quote:1lh1njss]

Ummmm timedelta is not changing untill the FPS are changed. Soo you meant "TickCount" or "Timer"?[/quote:1lh1njss]

Not if you're adding timedelta :)

But yeah, there are lots of ways you can measure the age of objects, and it's relatively easy to do. I'm not sure there would be any need for a built-in age timer.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Thu Oct 02, 2008 12:32 pm

[quote="deadeye":1e629jt3]
Not if you're adding timedelta :)

But yeah, there are lots of ways you can measure the age of objects, and it's relatively easy to do. I'm not sure there would be any need for a built-in age timer.[/quote:1e629jt3]
Oooooooooh adding... But why the hell add? Too many actions... it will be not good to add to every object time delta... why not just Timer (once) so when you have 500 objects CPU wont have to add 500 times per tick!
B
4
S
2
G
4
Posts: 719
Reputation: 2,938

Post » Thu Oct 02, 2008 1:44 pm

Addition is hardly an expensive CPU operation... I wouldn't worry about that! Storing the creation time is another perfectly good way of doing it - whichever is easiest, really.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Thu Oct 02, 2008 2:08 pm

I've made an performance tests for intensive Private Variable modifying.
[url:3fuqicig]http://www.scirra.com/phpBB3/viewtopic.php?f=16&t=1768[/url:3fuqicig]

I'll research "onCreate -> set to timer" method to compare which one is faster and under what circumstances.

Edit:
Added (in thread above).
B
6
S
3
G
6
Posts: 219
Reputation: 3,013

Post » Thu Oct 02, 2008 5:01 pm

[quote="Ashley":1rry7kbf]Addition is hardly an expensive CPU operation... I wouldn't worry about that! Storing the creation time is another perfectly good way of doing it - whichever is easiest, really.[/quote:1rry7kbf]
But nonstop adding to value is likely not needed... dont be like guys that made Crysis :?.
Ps. I saw that .cap in other Topic (handlingPV) and i have ~35fps. And the other is at constant ~75 (max).
B
4
S
2
G
4
Posts: 719
Reputation: 2,938

Post » Thu Oct 02, 2008 9:09 pm

i knew i could do it with UID, thats what i thought could work, and i dont need to know its true age, thats why an everytick adder wouldnt be good, and it seems like a waste. i use those when i need to time how long a missile can stay alive and stuff like that
B
52
S
7
G
6
Posts: 1,945
Reputation: 7,610

Next

Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 3 guests