destroy actors with same color

Hi Experts, can you please help to guide me on the requirement below:

There are :smile:
1) red bead, blue bead
2) press button as red button and blue button

If i press red button, only red beads will be destroy, and blue button is pressed blue bead and so on.

Thanks you in advance for the help.

Comments

  • KillerPenguinStudiosKillerPenguinStudios Member Posts: 1,291

    Hello @Game_AppAd‌,

    What I would do is create two game attributes. One integer attribute and call it something like color_number; then one boolean attribute and call it button_pressed.

    --In the button actor say;--

    When self color is red, change game.color_number to 1

    When self color is blue, change game.color_number to 2

    (continue for each color)

    Make another rule that says;

    When touched is pressed, change game.button_pressed to true

    Otherwise

    When touched is released, change game.button_pressed to true

    ~In the bead actors~

    --In the red bead actor say;--

    When game.button_pressed is true

    and

    when game.color_number = 1

    Destroy

    --In the blue bead actor say;--

    When game.button_pressed is true

    and

    when game.color_number = 2

    Destroy

    (continue for each color bead and added color)

    Hope that helps! :D

  • Game_AppAdGame_AppAd Member Posts: 10

    Hi Experts, thank you so much for the guide. I gonna test it out now. Thanks again.

  • Game_AppAdGame_AppAd Member Posts: 10

    Hi Experts, i am stuck at the rule -"when self color is red, change game_color number to 1". How should i go about it? Create a self attribute with integer, text or else?

  • wcsd9739wcsd9739 Member Posts: 37

    Not sure I know exactly what you mean, but here's a shot...

    First, make two boolean game attributes called RedPressed and BluePressed.

    If your Red Bead and Blue Bead are different actors, which I'm guessing is the case, simply give the Red Bead this rule, and a corresponding rule for Blue Bead:

    If game.RedPressed is true, Destroy

    If you're using the same actor for both Red Beads and Blue Beads, then give the actor a self attribute called Color that sets to 1 for red and 2 for blue, and so modify the above rule to include that, then add Blue's rule as well:

    If game.RedPressed is true and self.Color = 1, Destroy
    If game.BluePressed is true and self.Color = 2, Destroy

    Hopefully one of these methods works for you. If you still can't figure it out, then try posting a screenshot next time so we can get a better idea of your objective. Good luck! :)

Sign In or Register to comment.