This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2007-07-05 20:43:25

tommyturtle
Scratcher
Registered: 2007-07-05
Posts: 4

Questions about layers

Could someone explain more about layers?  How many layers can a project have?  Is the stage a layer?  Can I set a sprite to a particular layer and keep it on that layer?

I think I don't understand layers well enough, and in addition, there is a bug in the Scratch implementation (or one of my projects).  I expected the higher numbered layers to alway be behind the lower-numbered layers, but that's not always the case, as you can see if you run http://scratch.mit.edu/projects/tommyturtle/19522

Thanks for listening.

Offline

 

#2 2007-07-05 22:39:27

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

Re: Questions about layers

Think of layers as like a deck of cards or a bunch of transparencies with one sprite on each.  The number of layers is the number of sprites (including the background).  You can move a layer (sprite) to the front or you can move it back, though never behind the background.

Offline

 

#3 2007-07-06 02:04:53

Mayhem
Scratcher
Registered: 2007-05-26
Posts: 1000+

Re: Questions about layers

It would be very, very useful if somewhere on screen it showed the current number of layers, and which layer a sprite was currently on.  That and a "Send to back" block.


Web-spinning Spider:  http://scratch.mit.edu/projects/Mayhem/18456
3D Dungeon Adventure:  http://scratch.mit.edu/projects/Mayhem/23570
Starfighter X: http://scratch.mit.edu/projects/Mayhem/21825
Wandering Knight: http://scratch.mit.edu/projects/Mayhem/28484

Offline

 

#4 2007-07-06 11:19:05

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

Re: Questions about layers

Send to back can be accomplished with "move back 1000 layers" since moving back more layers than there are sprites just moves to the back.

I agree that the layer metaphor is not a very clear one---it took me a couple of days to be convinced I had it right.  Controlling the layering of sprites is quite difficult in the current system, since the execution order of "move to front" and "move back x layers" commands changes their effects.

My son was really looking for a z-axis system, where each sprite had a depth value and you could move to a specific depth.  This would make ordering sprites much simpler for the programmer, but a simple sort of the z-values would allow the same sort of layering as is currently used for rendering the sprites.  Instead of "move to front" and "move back n layers", the blocks would be "set z to <>" and "<z>"

Two problems with a "z" model
    * ties need to be broken when layering the sprites.  This may result in different layering in different implementations.

    * sprites should default to different depths.  Perhaps each sprite, when created, should get a 1 larger Z value than the largest current Z (assuming + is front and - is back).

Offline

 

#5 2007-07-06 12:48:52

Mayhem
Scratcher
Registered: 2007-05-26
Posts: 1000+

Re: Questions about layers

Problem I have had is that variable displ;ays appear to be included as layers, with no easy method of bringing them to the top layer.

I wanted one sprite to be in the foreground, so gave it the forward instruction.   It promptly concealed the variables.  If I move it backwards, I'll need to put in instructions for every other sprite to move back a given amount as well. 

I really don't want to have to tell every one of my sprites to go back a specific amount  hmm


Web-spinning Spider:  http://scratch.mit.edu/projects/Mayhem/18456
3D Dungeon Adventure:  http://scratch.mit.edu/projects/Mayhem/23570
Starfighter X: http://scratch.mit.edu/projects/Mayhem/21825
Wandering Knight: http://scratch.mit.edu/projects/Mayhem/28484

Offline

 

#6 2007-07-06 16:44:07

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

Re: Questions about layers

Controlling the layer for the variables *is* a problem.  It could be fixed in the "z" model by having the variables at a fixed depth.


Thinking about the Z model some more---it would be better to the background at +infinity rather than -infinity---that way Z becomes "depth".  The Z values would be useful for approx perspective transforms:
     set size to 100/(<Z> - <camera Z>) 

(Camera Z could be a variable or a constant, perhaps -10---no need for a new block.)

It might also be useful to have a block:  reset Z to layer number, which takes the current ordering of the layers (including the arbitrary breaking of ties) and assigns Z values based on the ordering.

I can see a lot of things that would be easy to do  in the Z model that are hard to do in the "deck of cards" model, and it certainly would be much easier to explain to novice programmers.

Offline

 

#7 2007-07-07 16:42:56

tommyturtle
Scratcher
Registered: 2007-07-05
Posts: 4

Re: Questions about layers

Thanks that's helpful

Offline

 

Board footer