Is there code to go to the frame you were previously on

Hello! I wonder if there is a code that sends you to the frame you were previously on like if there is a choose character frame and you go there how is there a way to send the player to the frame they were previously on. this is for the plus mod of Rythmania know more as ddr-type-game from @pumpkinhead

I spy with my little eye, a piece of code in the reference that will help you…

1 Like

thanks ill try it

A solution is to have a variable collecting your last visited frame and have the back action goto that variable number
this would give you more flexibility to choose when to use this function and when not

oh I didn’t think about that thanks

but one question how will you save the frame number to the variable

project.lastVisited= 5;

back action
gotoAndPlay (project.lastVisited);

ok I’ll try it

Here's a more specific answer of how this is done

(place code inside of a frame that extends over all the other frames)

DEFAULT -

/* Set to current frame by default */
window.LastFrame=[project.currentFrameNumber];

window.gotoLastFrame=function(){
if(LastFrame.length>1){
project.gotoAndStop(LastFrame[LastFrame.length-2]);
LastFrame.pop();
}else
alert("- NO MORE GOING BACK -");
};

UPDATE -

/* Set to last frame */
if(LastFrame[LastFrame.length-1]!==project.currentFrameNumber){
window.LastFrame.push(project.currentFrameNumber*1);
}

FUNCTION for LAST FRAME -

gotoLastFrame(); /* Use this anywhere in the project to go to the last frame */

Working example - (10.5 KB)

1 Like

Thanks for explaining it it helped me out well :)

1 Like