Help with a spawning button
sparx13
Member Posts: 97
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!
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
-
BarrytheBrave Posts: 134What 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
Thanks!