Discuss Scratch

Cub56
Scratcher
1000+ posts

Layering Variables

You can currently use

goback1layers

to move sprites into different layers.

In my game, I have an inventory consisting of several sprites that opens when the key E is pressed, so everything else should be underneath the inventory (the inventory should cover up everything currently on screen.)

When you make a new variable that you want to be displayed but behind another sprite the new variable will go straight to the front when you create it. So you would end up with something like this



I know you can set a variable to hide whenever the inventory is opened, not just go back several layers, but if you have a lot of variables it would need a lot of if-else blocks confirming the situation as to whether to show the variable or not when the inventory is closed.
(As in, a variable only shows on a certain backdrop, and every time the inventory is closed you would need an if-else to check whether the backdrop was the variable showing backdrop or not)

You could also do this with sprites but it could be very difficult to tell what layer a sprite is on because there isn't any way to see the layer of the sprite and there might be multiple sprites that need to be on top of the variable.

Last edited by Cub56 (Feb. 2, 2017 12:32:11)

EDO2012
Scratcher
100+ posts

Layering Variables

Why do you want to use the orange square? You could make it look a lot better (and have layering) with a text engine.
Cub56
Scratcher
1000+ posts

Layering Variables

EDO2012 wrote:

Why do you want to use the orange square? You could make it look a lot better (and have layering) with a text engine.
Too many assets and costumes.
MathlyCat
Scratcher
1000+ posts

Layering Variables

Cub56 wrote:

EDO2012 wrote:

Why do you want to use the orange square? You could make it look a lot better (and have layering) with a text engine.
Too many assets and costumes.
I mean it wouldn't hurt to try it for your project…
Though, I support considering I have many frustrations with layering on variables.
TheLogFather
Scratcher
1000+ posts

Layering Variables

If you have avoided Stage3D then you can move sprites in front of variable watchers.

If you are using Stage3D (or the things to be shown in front of the var watchers are on the backdrop) how about just using "when backdrop switches to [something v]" to hide the relevant var watchers?

Alternatively, how about making a list that contains all those backdrop names which should have the var watcher(s) hidden, and just keep checking if the list contains the current backdrop name?

WolfCat67
Scratcher
1000+ posts

Layering Variables

…Would this also work for Lists?
havegotofronthavegobacklayershavegotofronthavegobacklayers
…If so, that would be nice. I can see myself using this in the future for some reason…
WaffleChurro
Scratcher
100+ posts

Layering Variables

I support, it's a very useful idea

dvargasews
Scratcher
500+ posts

Layering Variables

WolfCat67 wrote:

…Would this also work for Lists?
havegotofronthavegobacklayershavegotofronthavegobacklayers
…If so, that would be nice. I can see myself using this in the future for some reason…
I'd prefer a more general
movesprite1tolayerfromfrontcan also be backmovesprite1forwardslayerscan also be backwards
Variables and lists could also be inserted into the blocks, like
movemoneytolayerfromfront
to relayer the variable money.
ZXMBXES
Scratcher
4 posts

Layering Variables

Really what you can do is have a sprite hide the variables, giving the ILLUSION that the sprite is covering the variables, when, really,
you are just hiding the variables when the character is “passing over” them.
There is another way to do this, and I will explain them both now;
When Flag Clicked
Forever
If <<X Pos> of <Sprite> = <>> <and> <<Y Pos of <Sprite> = <>> then
Hide Variable(s) <>
Else
Show Variable(s) <>
___________________
So I figured that way and there way you can hide them using your –mouse pointer– and the –say– block to hide variables above the sprite, and it is as simple as this;
When Flag Clicked
Forever
If <touching <mouse pointer>> then
Say <>
Else
Say <–Nothing–>
Hope this helped! Sorry that I couldn't use real scratch blocks it's just I get confused and stressed trying to the the ScratchBlocks and so please understand!

Powered by DjangoBB