I'm trying to create a RPG Game in AS2 and I have made a "shop". For example I got 50 exp and I enter the shop it still says 50 exp in my Variable, this is good but.... When i'm done in my store and want to go to the world/zone I lost my stats/variables it's 0 agian. This is what I got:
To enter the shop I got: onClipEvent (enterFrame) { if (_root.Character.hitTest(this)) { _root.VCam.gotoAndPlay(2); _root.gotoAndPlay(2); }
} to leave the shop I got: onClipEvent (enterFrame) { if (_root.Character.hitTest(this)) { _root.prevFrame() //or _root.gotoAndPlay(1) _root.VCam.prevFrame() //or _root.VCam.gotoAndPlay(1) } }
Is it possible that I keep my variables numbers when I go back to frame 1(world) agian, and how??
create a layer with one key frame that is on every frame that you need that variable on, just add frames, not key frames then put your variables in that key frame. I don't know much about as2 but if it were as3 you could just create a document class and have all your variables in there.
Are you using onClipEvent(load) to define your exp variable?
My guess is that on you are defining the variable on your player, and every time flash has to load the player, it calls back the onClipEvent, and sets the variable to 0. Don't define variables on your player movie clip, or it will be reset every time, and if the movie clip is ever removed, the variables will be lost. And again, I strongly recommend that you do not use onClipEvents at all. They are very tedius.
Also, if you are defining variables on the main stage, ex. player.exp = 0, a similar problem happens, and every time that frame is loaded, the variable is set to zero. Here's one way to fix it:
When defining the exp variable, check if it has already been defined: if(exp == undefined){ exp = 0; }
I recommend attaching the variables to the main stage rather than the player movie clip.