Reset all attributes
xacto
Member Posts: 146
Is there a simply way of reseting ALL attributes at once instead of changing each and every attribute separately?
Here is what is happening... when my player LIFE has reached "0" it goes back to the title screen, however when I hit "play" for the SECOND time all that stats/attributes and placed actors are where they were just before Life reached 0. I just want to reset EVERYTHING when it goes back to the tile screen.
I know I could just use the change attributes for each and every actor but that would take a long time... is there any other option?
Here is what is happening... when my player LIFE has reached "0" it goes back to the title screen, however when I hit "play" for the SECOND time all that stats/attributes and placed actors are where they were just before Life reached 0. I just want to reset EVERYTHING when it goes back to the tile screen.
I know I could just use the change attributes for each and every actor but that would take a long time... is there any other option?
Comments
When I play my game the second time, the spawned Actors are in the same place when the player dies. So I thought I could include the following code. (basically removing all enemies from the field so I can spawn them in again from scratch)
(Code is in the enemy actor)
Every 1 second:
Rule: When any conditions are valid: An attribute changes game.player.life equals 0 then Destroy this Actor
I can not figure out how to delete these Actors that were spawned before I play again. Any ideas?
So... it looks like I can reset all my integers with Change Attributes like; score, shield and life however, any Spawned or placed Actors can not be changed or reset after it has been run once. (as far as I can tell)
There is the "Destroy this actor" -- would it help if you could actually code the actor by name so the code could be entered someplace other then within the enemy Actor? (global integer?)
ex: An attribute changes game.player.life equals 0 then Destroy enemyOne
I am sure I am over looking something so obvious here, sorry... any help I would be grateful.
Side note: It would be great to have the feature to upload documents on the forum so you can view my code.
You know that for the Start button, whenever it is pushed, your global(game) attributes need to be reset. So set your "Score" and "Player Life" there instead of in the Otherwise of the "Player"
The title "Starfire" does not reset to its original size when you go back to the scene when you run out of lives. You can remedy this by adding a rule to it that resets its width and height when "Player Life" is 0.
If you add a rule to the Player, all the enemies, and explosions that when "Player Life" is 0, destroy it, then that should clear the game scene of any spawned instances before you return to the scene.
Finally, since you are restarting, you would need to spawn those first 6 enemies, since reset scene is not yet available. I would suggest that you create an actor that spawns when Player Life = 4. Or if you plan later to be able to gain life, then create an attrib that says that a new game has started, and toggle it at the same time as when Player Life =0 and when you reset Player Life.
So I recreated all the commands again. I thought it was working, but as soon as I tried to create SPAWN enemy actors (instead of placing them) they will not be destroyed when Player = 0.
I enter the code in all enemy actors that if Player = 0 then destroy.
It was working but now... no go.
I uploaded a new version.
The Title Scene Change Size in a Timer can be inconsistent. I suggest the Change Size in a Rule that activates when width is less than some set number.
The initial spawn position of the enemies needs to be reset.
Instead of having the change scene inside the Player actor that gets spawned, try adding it in something more static like the Initialize actor in a rule that checks if Player Life = 0, after .3 seconds Change Scene.
Since Player Life is an integer, you can just check the condition that it is less than 1, instead of having 2 conditions checking if it = 0, or is less than 0.
Instead of a timer within a timer, you could count how many enemies you spawn with an attrib in the initialize actor. When New Game is true and spawnedActors < 6, do the timer that spawns enemies and increment the number spawned.
Also in the Initialize actor have a new rule that checks when the number spawned becomes 5 or 6. There you can reset the NewGame, number of enemies spawned, and the initial spawn location.