How to select objects based on instance variable?

Get help using Construct 2

Post » Thu Feb 28, 2013 1:21 pm

I search the formum for a similar problem...bun I did not find the answer.
I have 10 instances of type : Ball, and they have the variable Inflated=true or Inflated=false
How ca I select only the Balls that are inflated?
I tried using System: Ball.Inflated = 1 to select de inflated balls....but it selects all the balls.
Any ideas.?
thanksCipriux2013-02-28 13:46:19
B
64
S
16
G
20
Posts: 471
Reputation: 16,131

Post » Thu Feb 28, 2013 2:21 pm

This should work:

B
6
S
1
Posts: 41
Reputation: 762

Post » Thu Feb 28, 2013 2:40 pm

Thank you @EightBitBattleCat ... it works
B
64
S
16
G
20
Posts: 471
Reputation: 16,131

Post » Thu Feb 28, 2013 2:53 pm

@EightBitBattleCat ...but realise I want a little more than that: how can I select the balls that are overlapping or collided with an inflated Ball ?...I want to inflate the other balls that collide with the inflated ball and deflate the balls that are collide with the deflated balls.
Thanks
B
64
S
16
G
20
Posts: 471
Reputation: 16,131

Post » Thu Feb 28, 2013 5:53 pm

I'm not sure. If a deflated ball hits an inflated ball which ball decides what should happen to the other ball?
B
6
S
1
Posts: 41
Reputation: 762

Post » Thu Feb 28, 2013 7:24 pm

@EightBitBattleCat sorry for the late response.
Actualy the ball idea is an abstract of my game. Here is another abstract test example with 10 bugs.
One of the bugs is infected and want to infect the others.
https://dl.dropbox.com/u/139926126/Forums/Bug_test.capx
The idea with the bugs will work on my curent project(Pipe Mania clone). Each pipe has colision squares so I can check if they are put in the right position starting prom the water tap(not in the game right now)by default the collision squares have instance variable touched=false only the watertap has the collision square instance variable set to true.
So if the object with the variable "touched=true"is touching other objects with "touched=false" i want to change the value tu "true".
https://dl.dropbox.com/u/139926126/Forums/Nuclear_waste398475934/index.html
Cipriux2013-02-28 19:25:59
B
64
S
16
G
20
Posts: 471
Reputation: 16,131

Post » Thu Feb 28, 2013 8:14 pm

Ah now I understand completely what it is you want to do, and I also understand why you're having problems.

What about simply having 2 sprites? One that's infected and one that isn't. Then, when an infected one hits another, you simply destroy the healthy one and replace it with an infected one and transfer the healthy one's angle, position etc. to the new infected one?

It's crappy code but it might work :P
B
6
S
1
Posts: 41
Reputation: 762

Post » Thu Feb 28, 2013 8:24 pm

@EightBitBattleCat nice idea...is not perfect but worth a shoot.
Thank you, I will try that
B
64
S
16
G
20
Posts: 471
Reputation: 16,131

Post » Thu Feb 28, 2013 8:31 pm

Here's a different approach.

The short version is that every tick a small infection "zone" is created on top of each infected bug and then destroyed after 3 ticks (determined by infectionSpread's "life" variable). If the infectionSpread object overlaps a bug it's infected.
It's probably also a poor way of doing it, but I think it's better than my first idea.

Hope you can use it!

https://dl.dropbox.com/u/2776515/Bug_test%20%28ebbc%29.capxEightBitBattleCat2013-02-28 20:32:27
B
6
S
1
Posts: 41
Reputation: 762

Post » Thu Feb 28, 2013 8:38 pm

@EightBitBattleCat thank you, I tried your idea and it's working Cipriux2013-02-28 21:09:52
B
64
S
16
G
20
Posts: 471
Reputation: 16,131

Next

Return to How do I....?

Who is online

Users browsing this forum: Lof, Yahoo [Bot], YoHoho and 24 guests