Simply spawning 3 objects in rotation.

di_mkdi_mk Member, BASIC Posts: 7
edited August 2016 in Working with GS (Mac)

Hello everyone!

My English is a little bit short but I’m gonna try to explain this as accurate as possible.

The codes are supposed to work like this.

  1. There are 3 objects in the list
    • [ A, B, C ]
  2. Every time a player clicks the box the next object will appear and the one that was there before will be destroyed.
  3. But “Object B” won’t appear unless “Condition_A” is true.
    • And that Condition_A's default state is False.
  4. So every time a player clicks the box “A” and “C” should appear on the screen in rotation.

And the codes are made up with 3 parts.


  1. Input
    • If Index Number < 3
      • Index Number +1
    • Elif Index Number >= 3
      • Index Number = 1
  2. Spawn Actor
    • If Index Number = 1
      • Spawn A
    • If Index Number = 2
      • If “Condition_A” is True
        • Spawn B
      • Else Index Number +1
    • If Index Number = 3
      • Spawn C
  3. Destroy
    • If Index Number != Actor Number
      • Destroy

ActorNumber

Actor A = 1
Actor B = 2
Actor C = 3

But somehow it goes wrong and only “Actor A” and Blank appears in rotation each time I click.

So I checked the log and I found out that after all the codes are successfully executed if the index number is 3, it runs the “Code: 1 Input” part again and again. And since the “Index Number” is 3 so it becomes 1. And then it runs that part again. This time “Index Number” becomes 2. But “Code: 2 Spawn Actor” part is still asleep. So it remains empty.

If I change the “Condition_A” to True, then when “Index Number” is 3, it “only” runs it twice instead of thrice like before. So only A and B actors appears in rotation.

Can anybody help me with this problem?

(I posted on the wrong board.

But where's the delete button?)

Comments

  • NNterprisesNNterprises Member, PRO Posts: 387

    I think you explained pretty well and have a good approach on it so far.

    In my game "Bizarre Blocks", you tap and change shapes. For the first couple levels (when condition X is false) you can only go from circle (actor A index 1) to square (actor B index 2). Then after like 40 points condition X is true and then you can be a triangle too (Actor C index 3). Then Condition Y happens and you can be a star also (actor D index 4). So i have the same setup kindof as you but a couple different things.

    1. Mine goes from index 1 to 2 before condition, then 1 to 2 to 3 after it is true. Why does yours skip over 2? Like why can't you make actor C be for index 2? You want it to be 1 to 3 before conditon, then 1 to 2 to 3 after condition right? I'm assuming the order matters right?

    2. My game only SWITCHES IMAGES. You are saying you want to SPAWN these things. Are you sure you need to spawn them or is it ok to just change the images only?

    What is your bug.zip file attached? Is it a GS example? (I can't open it right now...at work)

  • di_mkdi_mk Member, BASIC Posts: 7

    Whoa I wasn't expecting any comments this fast.

    And the order of the objects does matter. Also it must be spawned too.

    Attached file is a gamesalad project file and I read your other comment but I cannot find the delete button. Can you help me finding that button too?

    Thanks :)

  • di_mkdi_mk Member, BASIC Posts: 7

    Actually I tried changing "Spawning Actor" into "Change Image" mechanism but it doesn't matter because that is not the part that is making the problem.

  • NNterprisesNNterprises Member, PRO Posts: 387

    Yea I don't think you can delete threads. you can go in and click EDIT by clicking the top right settings button. Then change the title to Duplicate thread or something and put your comment/write up as *Sorry, see other thread or somehting.

    **There is a formula to give you a good easy way to count 1,2,3 and loop back to 1, i think it's something like %3 but you'll have to look into that I'm not really sure... google percent sign function gamesalad or try to find it in.
    http://help.gamesalad.com/gamesalad-cookbook/1-getting-started/1-11-glossary/

    I would do:

    Rule
    If index = 1, spawn A
    **---rule inside If touch is pressed, change index to 2
    __
    Rule if index = 2
    ---rule inside rule
    ---if condition = true, spawn B
    **-----another rule = If touch is pressed change index to 3
    ---Else for 2nd rule, change attribute index to 3
    __
    Rule if index = 3, spawn C
    **---rule inside If touch is pressed, change index to 1

    Then put in A:
    If index !=1 destroy

    Then put in B:
    If index !=2 destroy

    Then put in C:
    If index !=3 destroy

    If you figure out ** you can change this to something like your index+1

  • NNterprisesNNterprises Member, PRO Posts: 387

    Oh ok, if it is the same then I'd recommend using the change image then. For my blocks my images are called block1, block2, block3, block4.
    You can do a constrain attribute self.image to "block"..index
    Or do change attribute self.image to "block"..index every time which may be better in your case performance wise

  • di_mkdi_mk Member, BASIC Posts: 7

    Yeah it worked, but in my game there are 26+ objects and a lot more of other conditions to check so sadly it won't work for me :'(

    Actually it would work but the codes will get a lot more complicated..

  • di_mkdi_mk Member, BASIC Posts: 7

    omg I just figured it out.

    I'm such an idiot.

    In case that somebody might find this helpful, I'm gonna upload the example project file here. And I made a note inside the part that was causing the problem.

  • di_mkdi_mk Member, BASIC Posts: 7

    And thank you NNterprises I appreciate your help :)

  • NNterprisesNNterprises Member, PRO Posts: 387

    Thanks bud, good job and good luck

Sign In or Register to comment.