Help with a spawning button

sparx13sparx13 Member Posts: 97
edited July 2012 in Working with GS (Mac)
Hi In my game that I'm making I need help with a spawn button that I made.
In my game I have a, scrolling screen, a spawn button to spawn a warrior actor that is animated and another actor that when the warrior actor collides with it, it will have another animate behavior to attack this actor.
I have the button to spawn the actor in the position 880,80 but when I click the spawn button it takes several seconds for the warrior actor to come onto the screen, and when it does the warrior is scrollable.

Before I added the spawn rule and just had the warrior actor starting on the screen. The warrior's animate attack behavior attacked the other actor when it collided with it. But now it attacks when it is on the opposite screen section, I think this is due to the warrior being scrollable. Can someone tell me how to make the warrior on the non-scrollable layer and how to make it spawn in the right position?

Any help would be amazingly AWESOME!

Best Answer

  • BarrytheBraveBarrytheBrave Posts: 134
    edited July 2012 Accepted Answer
    What I would do is not make the button itself spawn any actors. Make a game boolean attribute called "spawnWarrior", which is initially un-ticked (false). Now in the button (on the non scrollable layer) have a rule that says:

    "when touch is pressed
    change attribute game.spawnWarrior to true
    After 0.5 seconds (as an example)
    change attribute game.span to false"

    Then have another actor called spawner, which is invisible and sits on the scrollable layer, that has a rule that says:

    "When attribute game.spawnWarrior=true

    (...Perform spawn)"

    This way the button can stay on it's non scrollable layer, but it actually sends a message to another actor on a different layer to spawn the warriors.

    Depending on the gameplay mechanics you would probably then want to change the first rule in the button to say:

    "when touch is pressed and game.spawnWarrior=false"

    As this would stop the user from spawning another warrior until the 0.5 (or whatever cool down time you set) is up.

    Hope that makes some sense!

Answers

  • OskarDeveloperOskarDeveloper Member Posts: 533
    edited July 2012
    First of all if you want the spawned actor to be non scrollable you have to put the actor that spawns it on a non scrollable layer. How to solve where he is spawning you just place the actor you want to spawn on the scene and copy its x and y. Then paste those numbers in the spawn attr actor.
  • sparx13sparx13 Member Posts: 97
    Is there a way I can make the button not scrollable but the warrior who spawns not?
  • OskarDeveloperOskarDeveloper Member Posts: 533
    edited July 2012
    Yeah but you will have to constrain the x and y of the button to the cameras x and y then you will have to add a - or a + after the constrain to move it where you want on the screen. Read this thread; http://forums.gamesalad.com/discussion/46904/constraining-an-actor-to-touch-but-with-an-offset#latest
  • sparx13sparx13 Member Posts: 97
    I found that thread a bit hard to follow and I couldn't work it out. Is someone able to give me a template or tutorial.
  • sparx13sparx13 Member Posts: 97
    Any help?
  • ironDanironDan Member Posts: 148
    If you look at the Scene you will see Attributes and Layers and if the box next to the Layers name is checked it's scrollable. When you make a HUD on a game with a scrolling scene like an endless runner for example you need the HUD Layer UNCHECKED. To be honest I'm having a difficult time as most probably will reading what kind of help you need, and a template for your specific situation may not exist. Think about it?...if you are trying to spawn the actor at position 880,80 then your camera would need to have position 880,80 within its camera view field otherwise the actor is already at that position but you won't see it until the camera moves into that position.
  • sparx13sparx13 Member Posts: 97
    so is there a way I can spawn an actor from a button on a non-scrollable layer to a layer that is scrollable.
  • sparx13sparx13 Member Posts: 97
    thanks so much it worked and made perfect sense.
    Thanks!
Sign In or Register to comment.