[Solved]How do I Know If This Is Using Resources?

Get help using Construct 2

Post » Fri May 09, 2014 11:59 pm

I have three hearts on my GUI. If the player is hit, he/she looses one life point, setting the first two hearts to red and the third one to an empty heart. The process continues until the player has ran out of life points. It's all controlled by one variable.

What I am wondering is, if there is a simpler way to implement this?
and
Will this code cause lag on my GUI? If I understand this correctly, the hearts are being placed there every frame?

Thank You
You do not have the required permissions to view the files attached to this post.
Last edited by Tekniko on Sat May 10, 2014 4:11 am, edited 1 time in total.
B
56
S
15
G
13
Posts: 826
Reputation: 17,675

Post » Sat May 10, 2014 12:04 am

That's a solid approach, common sense, I use the same thing.
Image
B
75
S
23
G
3
Posts: 673
Reputation: 9,283

Post » Sat May 10, 2014 12:08 am

I was going to comment on this on your other thread, but couldn't actually prove this causes lag, however, there is no good reason to test this every tick. You know exactly when the health value goes up or down, so call a function at that point that processes this code. That is ultimately more efficient.
ImageImageImage
B
71
S
22
G
249
Posts: 3,763
Reputation: 138,577

Post » Sat May 10, 2014 3:44 am

@blackhornet Could you give me an example of how this code might work? I am still a noob when it comes to Functions.

I will try to figure it out in the mean time.
B
56
S
15
G
13
Posts: 826
Reputation: 17,675

Post » Sat May 10, 2014 3:56 am

I've done this quickly, so there may be some missing cases. I also altered your health icons to 0-speed. You can also get away with just one heart object, not three, but that won't affect performance much.
You do not have the required permissions to view the files attached to this post.
ImageImageImage
B
71
S
22
G
249
Posts: 3,763
Reputation: 138,577

Post » Sat May 10, 2014 4:08 am

I was just coming back to say I had figured it out, lol. But I will review yours and see how they differ.

Edit
Exactly what I had come up with, thanks!
B
56
S
15
G
13
Posts: 826
Reputation: 17,675


Return to How do I....?

Who is online

Users browsing this forum: irina, UberLou and 13 guests