How to select objects based on instance variable?

0 favourites
  • 11 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • 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.?

    thanks

  • This should work:

    <img src="https://dl.dropbox.com/u/2776515/c2_pick.png" border="0" />

  • Thank you ... it works <img src="smileys/smiley20.gif" border="0" align="middle" />

  • ...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

  • I'm not sure. If a deflated ball hits an inflated ball which ball decides what should happen to the other ball?

  • 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.

    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".

    dl.dropbox.com/u/139926126/Forums/Nuclear_waste398475934/index.html

  • 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

  • nice idea...is not perfect but worth a shoot.

    Thank you, I will try that

  • 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!

    dl.dropbox.com/u/2776515/Bug_test%20%28ebbc%29.capx

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • thank you, I tried your idea and it's working <img src="smileys/smiley4.gif" border="0" align="middle" />

  • You're welcome :)

    In case you're curious, this is how I did it:

    <img src="https://dl.dropbox.com/u/2776515/c2_bugs.png" border="0" />

    I learned something from you as well. I hadn't considered the thing you've done, taking a large image and scaling it down for the sake of better graphics when the sprite is rotated.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)