how to spawn actors that are planned before

hey guys im workin on something new
so basically im not sure how to get on this certain thing which is like
its basically a match game you have to match the random shapes that pop up either by the shape or color

so how do i get that when two are lets say red cubes are spawned and the player touches both of them get destroyed. im still working on the whole spawning but i felt like if i can't get the main part of the game functional which is them matching i can't work on more stuff

any help please?

Comments

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

    I've been around here a long time and I'm not usually one to recommend a template immediately but in this case, it's probably easiest to start with something that already works and adapt it for your use:

    http://gshelper.com/woocommerce-search/keyword/match/search-in/product/cat-in/all/search-other/product

    But to answer your question, you can do something like this:

    When Touch is Pressed
         When game.touchCount=0
              change attribute game.firstTouched to self.myColor
              change attribute game.touchCount to 1
         Otherwise
              change attribute game.secondTouched to self.myColor
              change attribute game.touchCount to 2
         When game.touchCount=2
              When game.firstTouched=game.secondTouched
                   [it's a match!]

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

  • RawanAlodehRawanAlodeh Member Posts: 51

    @tatiang said:
    I've been around here a long time and I'm not usually one to recommend a template immediately but in this case, it's probably easiest to start with something that already works and adapt it for your use:

    http://gshelper.com/woocommerce-search/keyword/match/search-in/product/cat-in/all/search-other/product

    But to answer your question, you can do something like this:

    When Touch is Pressed
         When game.touchCount=0
              change attribute game.firstTouched to self.myColor
              change attribute game.touchCount to 1
         Otherwise
              change attribute game.secondTouched to self.myColor
              change attribute game.touchCount to 2
         When game.touchCount=2
              When game.firstTouched=game.secondTouched
                   [it's a match!]

    ive tried what you said, but both actors get destroyed on first touch

  • pHghostpHghost London, UKMember Posts: 2,342

    Yes, the reason is that once you press it once, game.touchCount is changed to 1 and the otherwise section is triggered as well. You need to work around that.

  • RawanAlodehRawanAlodeh Member Posts: 51

    @pHghost said:
    Yes, the reason is that once you press it once, game.touchCount is changed to 1 and the otherwise section is triggered as well. You need to work around that.

    would it be simpler if for example i have two actors of each, lets say red. and in each of them ill create a rule that if its touched change attribute, and the same in the other actor. and a rule in both that if both attributes are changed they get destroyed. or will this complicate things when i spawn with tables?

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

    @pHghost said:
    Yes, the reason is that once you press it once, game.touchCount is changed to 1 and the otherwise section is triggered as well. You need to work around that.

    It shouldn't be. That's the whole point of using Otherwise. If a rule says:

    When x=1
         do A
         change x to 2
    When x=2
    do B

    Then it will evaluate the second rule right after x is changed to 2 and both rules will trigger ("do A" and "do B"). But using Otherwise:

    When x=1
         do A
         change x to 2
    Otherwise
         do B

    Should only trigger the first condition and "do A."

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

  • RawanAlodehRawanAlodeh Member Posts: 51

    @tatiang said:

    @pHghost said:
    Yes, the reason is that once you press it once, game.touchCount is changed to 1 and the otherwise section is triggered as well. You need to work around that.

    It shouldn't be. That's the whole point of using Otherwise. If a rule says:

    When x=1
         do A
         change x to 2
    When x=2
    do B

    Then it will evaluate the second rule right after x is changed to 2 and both rules will trigger ("do A" and "do B"). But using Otherwise:

    When x=1
         do A
         change x to 2
    Otherwise
         do B

    Should only trigger the first condition and "do A."

    so why do both actors get destroyed when i touch one?

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

    Hmm, sorry, it might have to be:

    When game.touchCount=0
         When Touch is Pressed
              change attribute game.firstTouched to self.myColor
              change attribute game.touchCount to 1
    Otherwise
         When Touch is Pressed
              change attribute game.secondTouched to self.myColor
              change attribute game.touchCount to 2
         When game.touchCount=2
                When game.firstTouched=game.secondTouched
                    [it's a match!]

    I didn't test this or the previous suggestion... both were off the top of my head so my apologies if this isn't quite right. Should be close though. ;)

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

  • RawanAlodehRawanAlodeh Member Posts: 51

    @tatiang said:
    Hmm, sorry, it might have to be:

    When game.touchCount=0
         When Touch is Pressed
              change attribute game.firstTouched to self.myColor
              change attribute game.touchCount to 1
    Otherwise
         When Touch is Pressed
              change attribute game.secondTouched to self.myColor
              change attribute game.touchCount to 2
         When game.touchCount=2
                When game.firstTouched=game.secondTouched
                    [it's a match!]

    I didn't test this or the previous suggestion... both were off the top of my head so my apologies if this isn't quite right. Should be close though. ;)

    this is exhausting me. sorry for the bother, i did exactly what you said but its not working. the thing is, if i put in the otherwise rule "when touch is pressed" and put the other rules inside it, it doesn't work at all. but if i put them without the when touch is pressed they both get destroyed. i have uploaded the file into one drive if anyone can check it out and help me. ill be buying a template soon but i thought some of u could save me a little trouble again thanks for the help

    https://1drv.ms/u/s!Attl9x_Y_-9llwxjQm8DXb-Ap6kG

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

    Sorry that didn't work. In this case, the template might be your best bet.

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

  • pHghostpHghost London, UKMember Posts: 2,342

    I had a look at the project. The "when touch is pressed" is necessary in the otherwise section, because if it isn't that rule is activated ALWAYS. The problem is that your first rule (above the otherwise section) can never be fired.

    You have a combination of two conditions: game.Touches.Count = 0 and when touch is pressed. When touch is pressed, game.Touches.Count will always be 1 or more, so your conditions contradict each other.

  • pHghostpHghost London, UKMember Posts: 2,342

    How do you want this to work? Do you need to use two fingers and touch both at the same time, or do you touch one first, to 'select' it and then the second one?

  • pHghostpHghost London, UKMember Posts: 2,342

    You first need to work out the logic in your head. Otherwise you are shooting in the dark...

  • RawanAlodehRawanAlodeh Member Posts: 51
    edited April 2017

    looks like i havent figured it out, lol i thought i did but i messed things up.

    i want the first touch to select it and then the second one.

  • RawanAlodehRawanAlodeh Member Posts: 51

    what i did was have eg. red 1, and red 2 actors. and i had a game attribute for each and that one touch is pressed change attribute and when both attributes are 1 destroy. but what this did is when two of them match all red 1 and red 2 actors in the scene even the ones that aren't touched get destroyed. didnt think it quite through

  • pHghostpHghost London, UKMember Posts: 2,342

    @RawanAlodeh said:
    didnt think it quite through

    When tackling a new concept, it's often helpful to try and visualise the logic tree with pen and pencil. It is a good habit.

    Here is a way of doing it: http://bit.ly/2pwbhKn

  • RawanAlodehRawanAlodeh Member Posts: 51

    the way you did it only works in a certain way, i want it to be for all actors so that i can spawn it, and i can't with the way you did it because each ones prototype should be changed

  • pHghostpHghost London, UKMember Posts: 2,342

    What do you mean?

    You can spawn the ones in my example.

  • RawanAlodehRawanAlodeh Member Posts: 51

    didnt know it was possible to spawn custom duplicated actors? its an endless style gameplay

  • pHghostpHghost London, UKMember Posts: 2,342

    @RawanAlodeh said:
    custom duplicated actors

    I don't understand exactly what you mean.

    You can spawn the actors. Every time a new actor is spawned, you can randomise the shape and colour (or any other attributes you are using). Hard to be more specific, though, without knowing more about your game.

  • RawanAlodehRawanAlodeh Member Posts: 51

    @pHghost said:

    @RawanAlodeh said:
    custom duplicated actors

    I don't understand exactly what you mean.

    You can spawn the actors. Every time a new actor is spawned, you can randomise the shape and colour (or any other attributes you are using). Hard to be more specific, though, without knowing more about your game.

    ill pm you more details if that helps:)

Sign In or Register to comment.