Actor stop spawning after touch, restart spawning after contact with another actor, HOW?

CabacoCabaco Member Posts: 414
edited July 2012 in Working with GS (Mac)
Just like the title says, so I click my actor 1 that spawns another actor, after the first touch I want the first spawn actor to deactivate, which means I want it to stop spawing actors, not clickable, and once the other actor hits the ground I want the spawner to activate again and be able to spawn more actors again.
Any help?

Comments

  • MotherHooseMotherHoose Member Posts: 2,456
    @CabacoAppNews … you tell the computer that the spawn is done

    gameAttribute: spawnDone … boolean type

    on actor1:
    Rule: when (All)
    Event: touch is pressed
    Attribute: when spawnDone is false
    -Spawn actor2
    -changeAttribute: game.spawnDone To: true

    on actor2
    Rule: when
    Event: overlaps or collides with actor type ground
    -changeAttribute: game.spawnDone To: false

    image MH
  • CabacoCabaco Member Posts: 414
    Thanks! Actually I have another question. I have a game where there's a button that spawns actors, but I want there to be a limit of 5 to be spawnable, once that limit is reached, the button stops working, but can still be there. Then, your goal is to eliminate these balls, once there are less than 5 balls, make the spawn button work again. How can this be achieved?
  • MotherHooseMotherHoose Member Posts: 2,456
    @CabacoAppNews

    add gameAttribute … spawnCount … index type

    on spawnerButton
    Rule: when (All)
    Event: touch is pressed
    Attribute: game.spawnCount < 5
    -Spawn
    -changeAttribute: spawnCount To: spawnCount+1

    on ballActor:
    Rule: when
    Event: touch is pressed (whatever triggers the destroy of ball)
    -changeAttribute: game.spawnCount To: game.spawnCount-1
    -Destroy

    image MH
  • CabacoCabaco Member Posts: 414
    There's a slight problem, all of this is working, but when I get to 5 balls onscreen, and one of them is destroyed, they just keep showing up so the amount of balls as to always be 5. And what I want is to when the balls are 5 and one is destroyed, I want there to be 4 so that I can spawn one more if I want. Thanks for the help
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    @CabacoAppNews, are you saying that you want the 5th ball to be destroyed but not to cause another ball to spawn automatically?

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

  • MotherHooseMotherHoose Member Posts: 2,456
    just change when spawnCount < 5 … do spawn
    and do not change the spawnCount with the touch/destroy ball

    track the number of balls destroyed with another attribute
    have that attribute … restart the spawn (changeAttribute: spawnCount To: 0)

    the idea is to do the as many spawns as you want on screen
    destroy the balls (and track # of balls destroyed)
    restart the spawns

    you tell the computer when to do something
    (attributes for conditions to trigger)
    you tell the computer what to do
    (attributes for tracking that is done)

    image MH
  • CabacoCabaco Member Posts: 414
    Ok I made it so that they stop spawning automatically, now I cant quite figure out how to make them spawnable againa up to 5. I made a destroycount attribute. Sorry for the inconvenience
  • MotherHooseMotherHoose Member Posts: 2,456
    @CabacoAppNews … great! you are getting it!

    maybe something like when the destroyCount = 4
    changeAttribute: game.spawnCount To: 1
    will restart the spawn?

    image MH
  • CabacoCabaco Member Posts: 414
    It still doesn't quite work like the way I want it to work. What about just one ball on screen at a time and when there are no balls on screen, I'm the one who spawns it? Man, this has turned out to be quite difficult :)
  • CabacoCabaco Member Posts: 414
    Sorry, gotta bump it
Sign In or Register to comment.