Discuss Scratch

hemmerling
New to Scratch
15 posts

How to build menus and multi-page applications ( similar to HTML pages ) ?

Hello,
I am both interested in Scratch and Snap!

How to build menus and multi-page applications ( similar to HTML application with several pages, you click on a link or button, to pass to another page ) ?

Simple game application: Entry screen with menu options, which lead to setup / configuration page, to the game page, to a score page, to exit the game.

To be honest, I didn´t find any clue how to do that.
Any simple example available ?
Or is my approach totally wrong, and Scratch/Snap! games must be organized totally different ?
If so, how ?

Sincerely
Rolf

Last edited by hemmerling (April 5, 2018 05:19:39)

turkey3
Scratcher
1000+ posts

How to build menus and multi-page applications ( similar to HTML pages ) ?

Probably using broadcasts. https://en.scratch-wiki.info/wiki/Broadcast

hemmerling
New to Scratch
15 posts

How to build menus and multi-page applications ( similar to HTML pages ) ?

Means that any new “page” must be “code” which cleans the one-and-only screen and activates sprites ?
deck26
Scratcher
1000+ posts

How to build menus and multi-page applications ( similar to HTML pages ) ?

The easiest way to do this will be to have sprites for the links so when a sprite is clicked you can make an appropriate broadcast.

Assuming the pages are static rather than dynamic (an individual page doesn't change) you can have these as backdrops which you switch to. Using a variable for the name of the page you want to switch to will be better than a broadcast for every page - eg

when I receive [change-bd v]
switch backdrop to [next-bd v] // this uses the variable

I'd include the ‘links’ in the backdrops but then place a rectangular sprite in front of each link with a ghost effect so you can still see the link but can click on it. So for each page you then need to know where to place the links so probably store that information in lists.

There are various little problems to be solved along the way but that should get you started. Remember a sprite-clicked script can react differently according to the current backdrop.
Vicream_Creator
Scratcher
100+ posts

How to build menus and multi-page applications ( similar to HTML pages ) ?

hemmerling wrote:

Hello,
I am both interested in Scratch and Snap!

How to build menus and multi-page applications ( similar to HTML application with several pages, you click on a link or button, to pass to another page ) ?

Simple game application: Entry screen with menu options, which lead to setup / configuration page, to the game page, to a score page, to exit the game.

To be honest, I didn´t find any clue how to do that.
Any simple example available ?
Or is my approach totally wrong, and Scratch/Snap! games must be organized totally different ?
If so, how ?

Sincerely
Rolf
You could use sprites with like arrow costumes, or when X (let's say left) arrow pressed then broadcast “score page” or like when settings button clicked broadcast “config.”

And equip every sprites except the sprites that appears in the menu with this:
when I receive [score page or config.]
repeat (25)
change [ghost] effect by (4)
hide
clear graphic effects
end

equip the sprites that appears in the menu like this:

when I receive [score page or config.]
wait (0.5) secs
set [ghost] effect to (100)
show
repeat (25)
change [ghost] effect by (-4)
end

…and the backdrop with this

when green flag clicked
switch costume to [home]
when I receive [score page or config.]
repeat (25)
change [ghost] effect by (4)
switch costume to [score page or config.]
repeat (25)
change [ghost] effect by (-4)
end
end

Note: Ghost effects are just a fade effect so that it isn't a brutal ugly switch. You can just easily remove all of them..
HopsPlay
Scratcher
2 posts

How to build menus and multi-page applications ( similar to HTML pages ) ?

PE
supa-panda
Scratcher
100+ posts

How to build menus and multi-page applications ( similar to HTML pages ) ?

HopsPlay wrote:

PE
Please don't necropost

Last edited by supa-panda (June 8, 2023 15:05:07)


KUMQUAT WAZ HERE
burp

The flowing message was sponsored by Kumquat Co incorporated:
This is my signature. You can make one to by going to the forum home page and then scrolling down to the bottom. There you should see the following:

Finally press the “Change your signature” button.

09878901234321
Scratcher
500+ posts

How to build menus and multi-page applications ( similar to HTML pages ) ?

supa-panda wrote:

(#7)
Please don't necropost
Information on what necroposting is here.

Is this thing on?
HopsPlay
Scratcher
2 posts

How to build menus and multi-page applications ( similar to HTML pages ) ?

Sorry
LIZARD_OFFICIAL
Scratcher
100+ posts

How to build menus and multi-page applications ( similar to HTML pages ) ?

The best way is this:
Create a sprite only variable called “id”
define new_element [id]
set [id v] to (id)
create clone of (myself v)
set [id v] to [__main__]
define show gui
broadcast [Delete v]
new_element[background]
new_element[button1]
new_element[buttton2]
define hide gui
broadcast [Delete v]
when i receive [Delete v]
delete this clone
when i start as a clone
switch costume to (id)
show

i do this all the time and the code becomes much easier to handle

Powered by DjangoBB