how to destroy actor

Hi, I have one big problem..

I make game when 4 objects (actors) with diferent color falling down.. u can see it on this picture

I need when i click on any of actors (red, blue, purple or green), they would be destroyed all of them. But i have randomly spawning in the scene the same actors on 5 places on the top and when are 2 actors (one actor is all of these 4 objects (actors)) in the scene it destroy both. But i want only one of them. Only on which i clicked. I hope you understand what i mean and sorry, for my english. I'm not good in.

Thaks for help...

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    So that image above is a single actor? Then make a rule that says When Touch is Pressed --> Destroy Actor. Do not use When Mouse Button is Pressed.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • joshiwujoshiwu Member Posts: 207

    no, that is 4 separate actors tatiang, as he mentions in his post.

    so mark, you want to make a game level attribute, either an INterger or a Boolean.

    a rule that says if pressed set "deleterr" to true or 1
    then set a rule in the colored actors to "Destroy self" while "delete" is true.

    if youre trying to make it color specific then use an Int attribute and correlate colors with numbers (I.e. 1 = blue 2 = red)

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    @joshiwu His description seemed to contradict itself:

    @marek.binder@atlas.cz said:
    I make game when 4 objects (actors) with diferent color falling down..

    (one actor is all of these 4 objects (actors))

    And then these:

    @marek.binder@atlas.cz said:
    I need when i click on any of actors (red, blue, purple or green), they would be destroyed all of them.

    in the scene it destroy both. But i want only one of them. Only on which i clicked.

    I'm quite confused but if you understand it more power to you! :p

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • TempieroTempiero Member Posts: 24

    sorry, I'm bad in english.. there is picture.. and i hope now you will understand what i mean.

    i want when i click delete only 4 actors in line where i clicked and i want to stay another 4 same actors stay in the scene

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    You could store each actor's position in a table and then when one actor is clicked, destroy only those actors in the same column. I'll see if I can make you a demo.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Here's a demo that doesn't use tables.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • joshiwujoshiwu Member Posts: 207

    Wow. Tatiang. Very nice of you

  • TempieroTempiero Member Posts: 24

    thank you so much.. i will try it.. it looks very nice.. :))

  • TempieroTempiero Member Posts: 24

    Well I tried it and it doesn't work well.. idk why, but i think there will be problem that i have no like you one actor and 4 replicas, but i have 4 different actors in column.

  • TempieroTempiero Member Posts: 24

    Can u make it for 4 different actors in column? for one actor works it well.. but I can't make it like when i click on any of 4 actors that will destroy all of them in column but they're different than actor what i clicked.

  • TempieroTempiero Member Posts: 24

    I made it for all of 4 actors same like u have in your file, it destroys all for actors, but every actors in scene not only in column

  • TempieroTempiero Member Posts: 24

    And I forgot say that this 4 actors are spawning from 5 actors on the top and they're falling down, so I can't do it like you in your project, when u put every actors in the scene, because they're spawning on the top of scene and I they must have behaviors in prototype. Or how can I do it?

    Thanks

  • TempieroTempiero Member Posts: 24

    And i can i do it in any other way, because I have randomly spawning and sometimes are 2 this actors in column, so I want to destroy only actors what i clicked ( 1 actor like I said before I mean this 4 actors in column together)

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    You'll need to find a way to give each spawned actor a column value depending on its position on the scene. I don't know enough about your game to suggest the exact way but one method is to change the value of a game attribute in your spawner actor right before spawning (e.g. Change Attribute game.column to 3) and then have a behavior outside of any rules in your spawned actor that changes an actor attribute to that value (e.g. Change Attribute self.column to game.column). That passes the value of the attribute from the spawner actor to the spawned actor. You can then use the method in my demo to destroy actors that are in the same column. It doesn't matter if they are a single actor or multiple actors... if they have the same self.column value, they will be destroyed.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • TempieroTempiero Member Posts: 24
    edited March 2015

    Yea I know but is there any possibility(choise or i don't know how can i say it) that destroy only one of 2 actors in column? cause sometimes they're two actors very close to the other in the same column and it destroys all...

  • TempieroTempiero Member Posts: 24

    OK... I made it like you said, and it works, but I have maybe problem with the row, cause it destroys only actor what i clicked... only blue or red or green or purple and it doesn't destroy all of them..

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    The way I made my demo was to assume that each actor would have a self.column value. So if there were eight actors on the screen, their column values would look like this:

    1    2
    1    2
    1    2
    1    2

    If you clicked on any of the "1" actors, the other "1" actors would be deleted. Same for the "2" actors. You can see this in my demo by using a Display Text behavior to display the value of self.column.

    If you don't have your game set up this way, then it won't work that way.

    Can you post a screenshot of your actors with a Display Text behavior showing their self.column (or whatever you are using) value?

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • TempieroTempiero Member Posts: 24

    this is before spawning colors

  • TempieroTempiero Member Posts: 24

    for all of 4 colors i have the same behaviors like you can see here..

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Can you post a screenshot of your actors with a Display Text behavior showing their self.column (or whatever you are using) value?

    Here's what my demo looks like, for example:

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • TempieroTempiero Member Posts: 24

    yea, there is problem.. i made display text game.column and it looks like this

  • TempieroTempiero Member Posts: 24

    It changes, because I made this like you can see

    but it change every when something is spawn and it changes for every actors... i can't save this attribute for single actors (4 colors)

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    The value of self.column is going to depend on how (in what order) you spawn your actors. If you spawn them all at once, you can control their values easily. If you are spawning an actor here and an actor there, I'm not sure how you're going to determine that. Does each spawner only spawn actors in a certain column? Can you explain a bit more about how the game works? Is it a match-3 type game or something completely different?

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • TempieroTempiero Member Posts: 24

    yea each spawner only spawn actors in a certain column. There are 5 spawners on the top of screen. They spawn in random time random actors... i have there 5 actors with 4 colors actors... but it isn't important... now when I click on actor whis is in same column, it destroy only one what i clicked and no all of them.. but they like you can se have same column numbers

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited March 2015

    They need to have different column numbers. Are you setting that value from the spawner actor or are you typing it into each instance in the scene?

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.