How do I exclude numbers from a "choose" expression

Get help using Construct 2

Post » Thu Sep 24, 2015 2:12 pm

Well... that makes sense. It will surely work if you copy health to health2. You can leave all your conditions as they are and use health2 variable only to pick the lowest health alive.

But it's still a workaround and not a pretty solution, but I would probably also seriously consider this move instead of manually checking/fixing 25 000 events :D.

I would definetly not do it with every tick (this might affect your performance) but just copy health to health2 everytime health value change. I believe you have some "updateHealth" function? So I would put the copy part there.
ImageImageImage
B
27
S
16
G
74
Posts: 977
Reputation: 41,673

Post » Thu Sep 24, 2015 3:47 pm

BackendFreak wrote:It will surely work if you copy health to health2. You can leave all your conditions as they are and use health2 variable only to pick the lowest health alive.


Actually, once I picked the lowest health character alive in the family, I still don't see how I can modify the health of the object's instance variable... Is this possible?

I mean, health2 would be the family instance variable, and the family member will be selected, but how can I add health to the object instance variable without knowing which object it is, even if there is only one object picked?

As far as I know, it is not possible to modify "health" to the family object picked if "health" is not a family instance variable, even though all the object in the family have such an instance variable defined.
B
29
S
6
G
1
Posts: 347
Reputation: 2,725

Post » Thu Sep 24, 2015 4:35 pm

Ah yea. Well in this case you would need another function - let's call it - "adjustHealth".

1. Add one more Family instance variable "healthToAdjust".
2. Everytime champion got hit/healed you set "healthToAdjust" to X or -X.
3. Right after that you will have to run "adjustHealth" function which will check each champion/sprite (you said you have 4 of them so that should not be a problem) separately if "healthToAdjust" != 0 then "health" += "healthToAjdust". Then set "healthToAdjust" to 0 and "health2" = "health".

This is getting a bit complicated... but in your situation it might be worth a consideration.
ImageImageImage
B
27
S
16
G
74
Posts: 977
Reputation: 41,673

Post » Thu Sep 24, 2015 7:52 pm

Wow, thanks a lot for your time and explanations! I think your solutions should work. :)
I'll try it tonight and let you know how it goes. ;)
B
29
S
6
G
1
Posts: 347
Reputation: 2,725

Post » Thu Sep 24, 2015 9:11 pm

No problem ;). BTW I have played your game and... it's the best C2 game I have seen so far, I really love it ;). Very good Job! The only one thing I would change is the place of mana bar. I simply do not see it while playing because my left thumb is over it. This is very important to see it during fight so some top corner place would be better. But again, great game!
ImageImageImage
B
27
S
16
G
74
Posts: 977
Reputation: 41,673

Post » Fri Sep 25, 2015 3:11 am

@BackendFreak
Let me tell you something. You absolutely ROCK! :)
I tried your solution exactly as you proposed it, and everything works wonder! Now both effects are implemented nicely into the game, and my code is cleaner and shorter than it was before, also thanks to the advice of other people in the first replies, which also have my gratitude. But best thing is that I learned a lot. :)

Thanks for your kind words about my game. If you like the mobile version, chances are you will like the PC version I'm working on. The mana bar is now placed in the center bottom, but it's not as important as it won't be touch-based anymore and you shouldn't have your thumb before the screen. But I keep your feedback in mind for the next mobile update. ;)
B
29
S
6
G
1
Posts: 347
Reputation: 2,725

Post » Sat Sep 26, 2015 1:03 pm

Happy it works for you :). I will play PC version for sure ;).

What have you used for mobile version? Intel XDK or CocoonJS?
ImageImageImage
B
27
S
16
G
74
Posts: 977
Reputation: 41,673

Post » Mon Sep 28, 2015 10:30 am

I used Intel XDK for both iOS and Android version. Quite happy with it though it hasn't been easy to implement (I guess platform deployment is never easy).
B
29
S
6
G
1
Posts: 347
Reputation: 2,725

Previous

Return to How do I....?

Who is online

Users browsing this forum: tarek2 and 19 guests