Power-hit problem

game ongame on Sun Valley, California Member, PRO Posts: 79

I'm making a game that starts you off with plus-one "power-hit."

To stop people from constantly taping "Power-Hit" button, I had the "power-hit" button destroyed when attribute = 0. It worked great, but now I've decided to add an extra "power-hit" with ever +50pts you receive.

So here's the new problem. Once "power-hit" button is destroy and after you get 50pts (+1 power-hit) there is no button to press again to use on the new "power-hit."

I tried adding a "new rule", when "power-hit" = 1, change attribute to spawn "power-hit" button. But my Game won't even play when I added that rule for some reason. Maybe because the Game starts you off with plus-one "power-hit" already, so it keeps spawning the new "power-hit" button and over-powering Gamesalad?

I also tried "NOT" destroying the "power-hit" button when attribute = 0. And instead add a "new rule" when "power-hit" = 0, "change attribute" to false, and in "otherwise" turn "change attribute" to true. But that doesn't work as well. It just keeps letting me tap the "power-hit" button and going into the negative 0, -1, -2 etc.

What can I do to ether destroy "power-hit" button when 0, and reappear when you receive +1?

Or keep the "power-hit" button and when "power-hit" = 0 stop it from letting you tap it and going into the negative until you get +1 again?

I know this is kind-of lengthy... sorry

Sin, David

Comments

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

    I sent you this in a PM but it may benefit others or others may have improvements to it, so...

    You've created a recursive spawner (an actor that spawns itself immediately and repeatedly) which will crash Creator and any device it runs on.

    What you can do is to have the score check rule in a different actor from the power hit button actor. In the score check actor, when the score reaches game.lastScore+50, change a boolean game.spawnButton to true (it should be false initially). Have a timer set to after 0.1 seconds with run to completion checked and inside the timer change game.spawnButton to false. This has the effect of making game.spawnButton true for 0.1 seconds, just long enough for another actor to use the new value. In a button spawner actor, have a rule that says When game.spawnButton is true, spawn actor [power button actor]. In the power button actor, when touch is pressed change game.powerhit to game.powerhit+1 and then destroy the actor.

    Let me know if that works... it's off the top of my head but I think it's correct.

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

  • game ongame on Sun Valley, California Member, PRO Posts: 79

    On second thought, I think it is better if we don't destroy the "power button" at all. Just stop it from working and counting down (-1, -2, -3 etc.) when it's press once attribute = 0.

    Also because, if someone doesn't use their "power-hit" a new "power-hit" button doesn't spawn on-top of the old one.

    Any suggestions for pausing a "power-hit" button, when all "power-hits" = 0. Then enabling it again once +1 Attribute kicks in?

    Thanks again,

  • branditimusbranditimus Member Posts: 1

    I definitly would not destroy the actor, but change its position to somewhere off screen.
    I know spawn and destroy are both memory hogs. Better to just move it off screen. If they can't touch it then they can't trigger it.

    In your button actor

    Create an index attribute called start_y

    Change it's value to the y position of the button when available.

    Make a few rules in the button actor.

    1- If touch is pressed (do whatever it is your button does)

    2- If "power hits" = 0 (change attribute self position y to -100 or something off screen.)

    To bring it back -

    3- If "power hits" is > 0 change attribute self position y to start y

    hope that makes sense.

Sign In or Register to comment.