Having Problems with save load

Non-platform specific questions.

Having Problems with save load

Postby again » Sun Feb 27, 2011 4:42 am

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
Attachments
retro.zip
(3.76 MiB) Downloaded 128 times
Free windows mobile games like doodle jump and super mario bros
http://krenisis.freeforums.org/
again
 
Posts: 258
Joined: Wed Jan 19, 2011 7:06 pm
Score: 33 Give a positive score

Re: Having Problems with save load

Postby lcl » Sun Feb 27, 2011 7:43 am

I will check that soon. :wink:
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Having Problems with save load

Postby skydereign » Sun Feb 27, 2011 8:04 am

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Having Problems with save load

Postby lcl » Sun Feb 27, 2011 8:22 am

That's just what I found out as well.
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Having Problems with save load

Postby again » Sun Feb 27, 2011 8:31 am

Ok the code works if I dont die , but if I die and press l to load the last point I saved , nothing happens.
Free windows mobile games like doodle jump and super mario bros
http://krenisis.freeforums.org/
again
 
Posts: 258
Joined: Wed Jan 19, 2011 7:06 pm
Score: 33 Give a positive score

Re: Having Problems with save load

Postby skydereign » Sun Feb 27, 2011 8:37 am

On the load, you can add this if you want.
Code: Select all
if(ActorCount("retroman")==0)
{
    // create retroman
}
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Having Problems with save load

Postby again » Sun Feb 27, 2011 8:45 am

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?
Last edited by again on Sun Feb 27, 2011 8:46 am, edited 1 time in total.
Free windows mobile games like doodle jump and super mario bros
http://krenisis.freeforums.org/
again
 
Posts: 258
Joined: Wed Jan 19, 2011 7:06 pm
Score: 33 Give a positive score

Re: Having Problems with save load

Postby skydereign » Sun Feb 27, 2011 8:45 am

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...
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Having Problems with save load

Postby again » Sun Feb 27, 2011 8:55 am

Alright it works but his keydown events is wierd its a bit off when he gets recreated.
Free windows mobile games like doodle jump and super mario bros
http://krenisis.freeforums.org/
again
 
Posts: 258
Joined: Wed Jan 19, 2011 7:06 pm
Score: 33 Give a positive score

Re: Having Problems with save load

Postby skydereign » Sun Feb 27, 2011 9:12 am

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Having Problems with save load

Postby again » Sun Feb 27, 2011 9:32 am

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.
Free windows mobile games like doodle jump and super mario bros
http://krenisis.freeforums.org/
again
 
Posts: 258
Joined: Wed Jan 19, 2011 7:06 pm
Score: 33 Give a positive score

Re: Having Problems with save load

Postby skydereign » Sun Feb 27, 2011 9:41 am

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.
Attachments
retro.ged
(209.17 KiB) Downloaded 117 times
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Having Problems with save load

Postby again » Sun Feb 27, 2011 9:48 am

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.
Free windows mobile games like doodle jump and super mario bros
http://krenisis.freeforums.org/
again
 
Posts: 258
Joined: Wed Jan 19, 2011 7:06 pm
Score: 33 Give a positive score

Re: Having Problems with save load

Postby skydereign » Sun Feb 27, 2011 9:52 am

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Having Problems with save load

Postby again » Sun Feb 27, 2011 9:57 am

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.
Free windows mobile games like doodle jump and super mario bros
http://krenisis.freeforums.org/
again
 
Posts: 258
Joined: Wed Jan 19, 2011 7:06 pm
Score: 33 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest