Selecting one out of many actors? How to do it?

dieseljesusdieseljesus Member Posts: 50
edited November -1 in Working with GS (Mac)
Hey, have a new problem i need help with. Its a game where i bring out tokens/markers on the screen. Its a bit like a boardgame. These markers are of a few different kinds. However, i spawn many of the same. For example. If i need to keep track of trolls and gnomes and stuff in a boardgame. Then i might spawn say 5 trolls, 9 goblins, 22 gnomes etc.

Now comes the problem. I have one button to destroy them all, and then i have a "kill zone" where i can drag this marker/token to get it killed. Is there any way to make these markers selectable instead? Right now all actor are draggable, but i would like to be able to highlight the marker when its selected too, and if its selected i should be able to touch a "kill actor" button.
I would also like to be able to increase/decrease hit point graphics on these actors if they are selected. One example.

I press the trollbutton 5 times and get 5 troll tokens... i press the gnome button 5 times and get 5 gnomes... then one of my gnomes gets killed in the IRL-boardgame. Then i just touch one of the gnome tokens, press delete and its gone.... Also one of my trolls are boosted... then i select one troll token, and press a + button to boost it and the result is that i change that image.

Do you understand what i mean? I would like to be able to in some way store what token is selected and then delete that one, boost it or whatever.... is this only possible with arrays?

PLEEEASE help! :D

//Matt

Comments

  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    i dont really understand what you mean. You mean when you click on a token you want it to be highlited and then when its clicked again destroy it? Sorry im at work peepin at the forums while running my fathers deli and finishing artwork for my game, so im going a mile a minute and dont have time right now to sit down and think this threw lol
  • dieseljesusdieseljesus Member Posts: 50
    Hehe, no worries.... well, think of having 10 actors exactly the same... you should be able to select one of them, and then have the posibillity to change its state, highlight it or whatever. If i have max 10-15 actors its easy since i can give them all their own attribute... Say "Token1" to "Token15".... BUT with unlimited tokens, its harder. Any ideas?

    Why i want it selectable is because i dont want the "kill zone" where i drag the markers... i want just be able to highlight it by clicking ad then being able to press a delete button on the side of the screen.
  • ToastKittenToastKitten Member Posts: 360
    ... what?
  • dieseljesusdieseljesus Member Posts: 50
    Aargh! Its not difficult when you see it graphically.....

    Ok, here we go again:

    1. I have 1 button that spawns an actor.
    2. The actor have an image of a strawberry cake.
    3. I press this button 55 times = i have 55 actors on stage
    4. I touch one of these strawberry cake actors.
    5. When i touch it, it is selected = Its highlighted to show that its selected.
    6. Then i press a button where it says delete... that actor is deleted. The one that is selected that is.

    Its basically like a desktop on a computer... if i select an icon, i can press the delete key to delete it.... I DONT have to drag it to the trash can. is THIS possible without arrays?

    simply put... have 10 different spawn points where i can spawn unlimited actors... then select one of them and being able to deltete it.... Simple concept, but how to do it?
  • forkliftforklift Member Posts: 386
    This should be solved with a boolean attribute inside the actor itself. You could call the boolean 'selected'.

    If cake=touched, change attribute self.selected to true

    if self.selected = true, then destroy on input/keypress/touch/etc.
  • ToastKittenToastKitten Member Posts: 360
    I love strawberries, and therefore will love answering this question :3

    So you could set up your strawberry actor to have a boolean attribute "selected"
    Then you could also have a boolean game attribute "killSelected"

    For your strawberry actor, have a rule set up like

    if pressed
    -if selected is false
    --selected is true
    -otherwise
    --selected is false

    if selected = true and killSelected = true
    -destroy

    Then for your button, you could have something set up like

    if pressed
    -killSelected = true
    -timer after 1 second
    -- killSelected = false

    Let me know if this helps!

    -TK
  • dieseljesusdieseljesus Member Posts: 50
    Hey, thanks for your answers. Well, the problem with this is that with this code:

    ----
    if pressed
    -if selected is false
    --selected is true
    --Change image to Selected Image
    -otherwise
    --selected is false
    --Change image to Unselected image
    ----

    I get this loop. Also. I need it to be unselected when i press the next actor.

    1. I have 5 actors that are the same.
    2. I press actor one. It is selected
    3. I press actor four, than one is selected instead. See what i mean?

    I tried to figure this out before by adding more flags, but i get dizzy thinking about it! :D

    Hehe, i really hope this can get solved.... thanks btw for all help! :D
  • ToastKittenToastKitten Member Posts: 360
    I'm guessing the loop happens because it's in the same rule... give me a sec, I'm editing this post with a fix and a possible method for the new situation that you've described :3

    EDIT: brb with an example/template
  • dieseljesusdieseljesus Member Posts: 50
    Hey thanks.... yes, the loop is the "else" attribute there. I get a flicker because i have different images in each of those.

    What i think will be a problem is this:

    1. I can select one brick/token/plate/actor or whatever.... but when i select another actor. It has to UNSELECT the last one used.

    Will it be a problem?
  • dieseljesusdieseljesus Member Posts: 50
    What i need to be able to do is this:

    1. When one actor is selected, i want it to be deletable by pressing delete.
    2. WHen one actor is selected. I want to be able to press a + and - sign to change its image to images with higher or lower number.....
    3. I want to be able to go back and forth between these actors to change them with the + and - but also delete....

    One heck of a problem huh? :D It would seriously change the way i have done this app now but also give me more space for other things in it.

    Right now i have 8 different spawn buttons.... i spawn actors with numbers on them.... 1,2,3,4, etc up to 8..... But if its solved i need one spawn point where i can spawn an actor with a 1 on it and then a + and a - button where i can change the numbers.
  • dieseljesusdieseljesus Member Posts: 50
    Hey that seem to be what i need! :D
  • dieseljesusdieseljesus Member Posts: 50
    Tried to download it but i cant! :(
  • dieseljesusdieseljesus Member Posts: 50
    Its in "Chess Game Format"
  • ToastKittenToastKitten Member Posts: 360
    Chess format?

    Uhh maybe search for it inside of GS? Idk, I've never downloaded a project off the web :/
  • forkliftforklift Member Posts: 386
    simply rename the .game to .zip, then double click it to unzip. Otherwise yes, it will pull up the chess application. Once unzipped, run from GS.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Sounds like you may have it figured out already, but the key is to have those booleans as self attributes and not game attributes. Otherwise they will be triggered in all the other instances of that prototype. Self attributes will only be activated in that one particular instance.
  • dieseljesusdieseljesus Member Posts: 50
    Thanks for all the help guys.... I have some sort of problem now tho. I have done all of it but something is colliding inside the script for the tokens...When i add that, i lose the posibillity to drag the tokens. looking into it now.
  • dieseljesusdieseljesus Member Posts: 50
    Wohaa... got it working. Thanks ALOT guys. The problem now is that i have 10 rules per actor. Its not just this functionality. Its also functionality that gives each actor a random number, to make the drag n drop function work good.

    Another thing... what mechanics should i use to be able to + or - the actor?
    I have an idea, but its too much different variables in my head now to work this out.
  • dieseljesusdieseljesus Member Posts: 50
    http://gamesalad.com/game/play/90012

    Here is somewhat an idea of what i have now..... I have stripped it down and did some quick and dirty buttons etc there.. i dont want to give away too much of what im doing yet.....
    sorry for slow loading, but everything is still in there, But off screen.

    But the question now is....

    How can i do so the + and - will change images to a 2/2, 3/3 etc on each token?
  • ToastKittenToastKitten Member Posts: 360
    I'll look at it once I get back from a study session... In the meantime, I'd say just make an integer attribute and if your actor is selected and the + or - key is down... if image = 1, then 2, if image = 2, then 3, if image = 3, then 1.... Idk if that's what you're asking or not.

    Like I said, be back later!
  • dieseljesusdieseljesus Member Posts: 50
    Solved some thins. Now I can change 2 different values showed as text on the tokens. One problem is if i change one cards values, it doesnt get reset all the time when i spawn a new one... Also, i have some probs showing the text.

    i want to show 2 different values on the token.... like power and toughness..... 1 / 2, 1/ 1, 3/5 etc.... i can change and control those values.

    The problem now is that would like to have a "display text" attribute showing "Self.Power / Self.Toughness". Is that possible? Because if i put two different Display Text attributes there, they get on top of each other!?
  • Rob2Rob2 Member Posts: 2,402
    using the concatenate operator .. combined with some formatting codes you can achieve quite a bit with the display text behavior

    you need to concatenate them with a \n (newline) to give you two lines

    self.power.."\n"..self.toughness

    Synth went into plenty of detail here http://www.gsproforum.com/viewtopic.php?f=21&t=111

    You could add labels to your attributes as well if you wanted all with the single display text behavior
  • dieseljesusdieseljesus Member Posts: 50
    Perfect. Got that one working too now. Now the only thing is this:

    i can spawn token after token with say a 1/1 value.... if i change a few of them, i still can spawn 1/1 tokens.... but as soon as i delete the last selected one, i get left overs from the last selected one (The values are transfered from the deleted one to the new one!) and its not possible to change the new tokens values

    Edit: Cant seem to solve this "left over" from the last token spawned... if someone would like to help me by taking a look at it, and maybe help me optimize this. I will of course include you into the credits etc. I would appreciate it alot.

    Btw, thanks to all for helping me this far. I couldnt have done it without you! :D
  • dieseljesusdieseljesus Member Posts: 50
    Hey guys.. thanks for all help. Now i am almost done with the app... or atleast done with v1.0

    I have some bugs tho and was wondering if someone would like to put 5-10 minutes to check my main behaviours for the tokens to see whats wrong with them. I dont think its anything dificult.

    Here's what it looks like right now, visually i mean. Check it out and maybe someone like ToastKitten could help me out if you have time? You have done a bunch for me and i really really appreciate it, but could need some aditional help! :/

    Check it out... this is a screenshot of the main gameboard!
    http://www.minorempire.se/mtggrimoire/ss-game.png
Sign In or Register to comment.