Page 1 of 1
Having Problems with save load
Posted:
Sun Feb 27, 2011 4:42 am
by again
Ok the problem Iam having is 2 problems . The 1st problem is when my actor gets destroyed and I load the game the actor doesnt appear. The 2nd problem Iam having is the view does not show up where its supposed to be. All the save seems to be doing is saving my position.
Variables
X , Y for the main actor
vX , vY for the view
Controls
Arrow keys to move left ,right,up,down,
L = load game
S =save game
Re: Having Problems with save load
Posted:
Sun Feb 27, 2011 7:43 am
by lcl
I will check that soon.
Re: Having Problems with save load
Posted:
Sun Feb 27, 2011 8:04 am
by skydereign
Your keydown for l looks like this.
- Code: Select all
saveVars("t.file", "place");
X=retroman.x;
Y=retroman.y;
vX=view.x;
vY=view.y;
I assume you wanted this to load. If so wrong order, and wrong function.
- Code: Select all
loadVars("t.file", "place");
retroman.x=X;
retroman.y=Y;
view.x=vX;
view.y=vY;
Also for you keydown s event, you should have this.
- Code: Select all
X=retroman.x;
Y=retroman.y;
vX=view.x;
vY=view.y;
saveVars("t.file", "place");
Lastly, your vY variable is not included in the save group place.
Re: Having Problems with save load
Posted:
Sun Feb 27, 2011 8:22 am
by lcl
That's just what I found out as well.
Re: Having Problems with save load
Posted:
Sun Feb 27, 2011 8:31 am
by again
Ok the code works if I dont die , but if I die and press l to load the last point I saved , nothing happens.
Re: Having Problems with save load
Posted:
Sun Feb 27, 2011 8:37 am
by skydereign
On the load, you can add this if you want.
- Code: Select all
if(ActorCount("retroman")==0)
{
// create retroman
}
Re: Having Problems with save load
Posted:
Sun Feb 27, 2011 8:45 am
by again
skydereign wrote:On the load, you can add this if you want.
- Code: Select all
if(ActorCount("retroman")==0)
{
// create retroman
}
I added this command to the load but its doesnt work. What should I make the parent?
Re: Having Problems with save load
Posted:
Sun Feb 27, 2011 8:45 am
by skydereign
Yeah, I forgot you aren't using your view actor to save and load. You really should, as the view will always be there. You may note that when retroman is destroyed, it can't have keydown events...
Re: Having Problems with save load
Posted:
Sun Feb 27, 2011 8:55 am
by again
Alright it works but his keydown events is wierd its a bit off when he gets recreated.
Re: Having Problems with save load
Posted:
Sun Feb 27, 2011 9:12 am
by skydereign
After a short investigation that is because you are constantly changing vX/vY. You are not treating it as a saved variable. Look in the view's draw actor event. Remove that and it will work.
Re: Having Problems with save load
Posted:
Sun Feb 27, 2011 9:32 am
by again
Ok I erased that from the draw actor but his climbing skills is extra after he is recreated. I think its doing something wierd with the filled regions that move the screen up. Can you give me the code to have the screen move up when the retroman charactor moves up. Maybe that will fix the funky movement.
Re: Having Problems with save load
Posted:
Sun Feb 27, 2011 9:41 am
by skydereign
Not really sure what you mean by funky movement. If I were you I'd remove the whole filled regions part but one thing that might be happening that you would consider weird is setting your yvelocity. Make sure to set it to zero when loading. Here's a version with all the previous changes, using this tell me how to replicate the problem.
Re: Having Problems with save load
Posted:
Sun Feb 27, 2011 9:48 am
by again
Ok I see 2 things that we didnt discuss that makes a big difference.
On loadGame
1) On the create actor I have it set 0,0 and you have it set X,Y .
2) You have an if and else command that I didnt have.
Re: Having Problems with save load
Posted:
Sun Feb 27, 2011 9:52 am
by skydereign
The if we did discuss, the else was my optimization. What you should have had if you were following my advice was this.
- Code: Select all
loadVars("t.file", "place");
if(ActorCount("retroman")==0)
{
CreateActor("retroman", "retro1", "(none)", "(none)", 0, 0, true);
}
retroman.x=X;
retroman.y=Y;
x=vX;
y=vY;
That would do the same thing.
Re: Having Problems with save load
Posted:
Sun Feb 27, 2011 9:57 am
by again
Yes I meant the else as I had the if already. Ok it works solid , Iam going to use this type of coding in other games and see how I can make it fit. Once I have this down pat , I make a tutorial explaining not just how to do it , but why it works. Thanks alot skydereign I really needed to figure this out.