Fangames > Programming Questions

Resetting Issues

(1/1)

bananaguy12:
So I am using yutuu engine, and I want an object to change its sprite when I press a button (I'm using T). I can do this, but when I reset (press r) it reverts the sprite back to the original. How can I make the object stay the sprite that it is toggled to?

patrickgh3:
The way restarting (pressing R ) in yuuutu works is kinda wonky. First a file called 'temp' is saved containing the save file number: 1,2, or 3. Then game_restart() is called, which restarts the game as if you closed it and reopened it. Upon startup, the game the notices the temp file, deletes it, then loads the save data from the save file it indicated by going to the correct room and spawning the player in the correct place.

So, if you want effects to persist when you press R in default yuuutu, you have 2 options the way I see it. First, you could save those effects in a save file to be loaded again when the game restarts, but that's pretty painful and inefficient. The second is to alter the process above so that game_restart() is not called, and your effects can persist. Other engines like Seph's do it this way (not using game_restart()) and it's just simpler.

So, you could either examine Seph's engine (or similar) and modify your current project to use that style of saving and loading, or you could start fresh from a copy of Seph's engine (or similar, KS!) and import your resources from your project into that. It's up to you; if you're not that comfortable with scripting in GML I would suggest the second method. I can help you with both; it might be easiest to do it through Skype, idk.

Once you have a loading process that doesn't use game_restart, to have effects persist when you press R, either save values in global variables or mark objects as Persistent, which means even when you change rooms the objects remain present with all their values. Hope this helps!

Navigation

[0] Message Index

Go to full version