Skip to main content
Participant
March 7, 2019
Question

Having issues with coding in HTML5 for making a looping menu in a choose-your-own-adventure game

  • March 7, 2019
  • 2 replies
  • 460 views

So the idea is to make a menu with a classic tween animation that will fade in the title screen and the start button and then, after passing a certain number of frames, would fade to black. Afterwards, it'll loop back to the beginning and start over again until the player clicks the start button. The issue I'm having is that the button will appear only when it first starts, it disappears after it loops.

Heres the run down:

By frame 119, I have the button already faded in and programed to jump to frame 238 to start the game. I labeled the frames that the button is programmed to jump to for the sake of ease incase if I have to move the code to a different frame so heres the labels I used so heres the labels and their frame numbers: "Title=frame 1", "start=frame 119", "after_start= frame 238"

Heres the code:

Frame 119:

/* Click to Go to Frame and Play

Clicking on the specified symbol instance moves the playhead to the specified frame in the timeline and continues playback from that frame.

Can be used on the main timeline or on movie clip timelines.

Instructions:

1. Replace the number 5 in the code below with the frame number you would like the playhead to move to when the symbol instance is clicked.

2.Frame numbers in EaselJS start at 0 instead of 1

*/

this.start.addEventListener("click", fl_ClickToGoToAndPlayFromFrame.bind(this));

function fl_ClickToGoToAndPlayFromFrame()

{

this.gotoAndPlay("after_start");

}

Frame 238:

/* Stop at This Frame

The  timeline will stop/pause at the frame where you insert this code.

Can also be used to stop/pause the timeline of movieclips.

*/

this.stop();

/* Click to Go to Frame and Play

Clicking on the specified symbol instance moves the playhead to the specified frame in the timeline and continues playback from that frame.

Can be used on the main timeline or on movie clip timelines.

Instructions:

1. Replace the number 5 in the code below with the frame number you would like the playhead to move to when the symbol instance is clicked.

2.Frame numbers in EaselJS start at 0 instead of 1

*/

this.trigger.addEventListener("click", fl_ClickToGoToAndPlayFromFrame_2.bind(this));

function fl_ClickToGoToAndPlayFromFrame_2()

{

this.gotoAndPlay("title");

}

Any suggestion on having the button loop with the rest of the menu?

This topic has been closed for replies.

2 replies

kdmemory
Inspiring
March 8, 2019

Oh, I take that back what I said about your label names. I can see from the scripts that you named them alright.

But apart from that, the other things I said still stand.

Klaus

Participant
March 8, 2019

I'll upload the game very soon. I moved on a little bit after this so there's some progress outside of the menu that I made. I apologize for my library being a absolute disaster at the moment. Thank you.

Edit: here's the link:feed_me_1_DC.fla - Google Drive

kdmemory
Inspiring
March 8, 2019

Hi David

Right now I am terribly busy with a project of my own (deadline: tonight ). I'll download and look at your file tomorrow.

Klaus

kdmemory
Inspiring
March 8, 2019

Hi David

Let us first de-clutter your script:

Frame 119:

this.start.addEventListener("click", fl_ClickToGoToAndPlayFromFrame.bind(this));

function fl_ClickToGoToAndPlayFromFrame()

{

    this.gotoAndPlay("after_start");

}

Frame 238:

this.stop();

this.trigger.addEventListener("click", fl_ClickToGoToAndPlayFromFrame_2.bind(this));

function fl_ClickToGoToAndPlayFromFrame_2()

{

    this.gotoAndPlay("title");

}

I quote: "... a classic tween animation that will fade in the title screen and the start button and then, after passing a certain number of frames, would fade to black. Afterwards, it'll loop back to the beginning and start over again until the player clicks the start button."

Right now I can see nothing in your script that makes the playhead jump back after a certain number of frames to start your classic tween again. There must be something before it reaches frame 238 automatically.

Then are you serious about your label names? "Title=frame 1", "start=frame 119", "after_start= frame 238". Are these really your label names??! In your place I would immediately remove empty spaces, upper cases and equal signs. And the numbers as well. Just call them "title", "start" and "game". Or what ever you like but in these patterns.

What is actually happening between frame 1 and frame 119? Is that the frame-span where your fading-in and fading-out classic tween takes place? Or does that happen between frame 119 and frame 238?

You say "By frame 119, I have the button already faded in and programed to jump to frame 238 to start the game." So how come that the button disappears along the way in the first place?

You know what, I appreciate that you tried hard to describe your issue in detail but it is very confusing and brings up more questions than it answers. How about you share your file (if it isn't a megabyte monster)? Via Google Drive, We Transfer, Dropbox etc.

Klaus