Discuss Scratch

tigaire
New Scratcher
5 posts

Layering and moving off-screen

Hi, I just did my first Scratch project and the only two (thankfully minor) issues that I had with it were:

1) Is there really no better way to do layering than pulling something to the front and then shoving it back some number of layers which is based on the number of sprites currently on the screen (which you seemingly have no access to)? Nor can you see where another object is in the z-ordering (which would at least give me something to work with).

2) It seems that when you're scrolling something off the screen (using move commands) that it won't leave the screen, but just stop when (maybe?) the center gets to the edge of the screen. But even then, I've tried scrolling things (toward the left in my project) and then checking the X position until it was > 239 (to then delete the clone). Which would (sometimes) never happen and the object would just sit at the edge of the screen.

You can see the project here:
http://scratch.mit.edu/projects/11566473/

I mostly worked around these issues, but not entirely and it feels like hopefully I missed something.

Thanks!
DotDash
Scratcher
1000+ posts

Layering and moving off-screen

tigaire wrote:

Hi, I just did my first Scratch project and the only two (thankfully minor) issues that I had with it were:

1) Is there really no better way to do layering than pulling something to the front and then shoving it back some number of layers which is based on the number of sprites currently on the screen (which you seemingly have no access to)? Nor can you see where another object is in the z-ordering (which would at least give me something to work with).

2) It seems that when you're scrolling something off the screen (using move commands) that it won't leave the screen, but just stop when (maybe?) the center gets to the edge of the screen. But even then, I've tried scrolling things (toward the left in my project) and then checking the X position until it was > 239 (to then delete the clone). Which would (sometimes) never happen and the object would just sit at the edge of the screen.

You can see the project here:
http://scratch.mit.edu/projects/11566473/

I mostly worked around these issues, but not entirely and it feels like hopefully I missed something.

Thanks!
This belongs in the Help With Scripts section.
DadOfMrLog
Scratcher
1000+ posts

Layering and moving off-screen

Welcome to Scratch.
(I think us parents had better start some kind of ‘why should kids have all the fun with Scratch’ club…)
(Oh, and nice project, BTW!)


1. Layering…

You can move back by by a negative number of layers - i.e. move forwards
Note that the layering is something of a tricky businiess, and I'm not sure there are many people who have ever really understood what's going on. I only worked it all out very recently…

First of all, *everything* has a layer - even hidden sprites, even any variables that have ever been shown (and then hidden), and even any reporter blocks (e.g. x position, costume #, timer, etc.) that you've shown (and then maybe hidden again).
However, you have no control over the layering of those reporters from within the script itself -apart from when you show one of them, which makes it come in front.

Secondly, if you start moving things to front (or around in layers), you've got to be pretty sure that you get execution order of your scripts just right (or else you might find a sprite that you want topmost ends up under another sprite that ran its “move to front” after the first sprite). For example, having several things move to front on “when GreenFlag clicked” is often a bad idea, because you don't necessarily know what order those different scripts will get run. It's better to have some kind of central ‘control’ script, and have it do several ‘broadcast-and-wait’ in the order you want to tell other sprites to change their layering (and make the other sprites change their layering in response to the broadcasts).


2. Off-screen sprites…

Yeah, sprites are not allowed to completely disappear off the edge of the screen - they always leave a few pixels-worth at the edge still visible. This was a design decision apparently to avoid confusion & despair for young scratchers who might be worried about ‘losing’ their sprites. (TBH, it seems to generate more confusion…)

There is a (slightly tedious) workaround, which is to switch your costume to vector mode (if it's not already), then place a filled rectangle (i.e. without outline) around your costume, so that the rect extends well beyond the edges of the existing costume, and then make that rect transparent. Your sprite still never actually goes off the edge of the screen, but because the part that does remain on-screen is transparent…
(You can see this technique used to good effect on my recent 3d demo project to make large sprites slide gracefully off-edge-of-screen, for example.)


Hope that's useful and made some sense!

Last edited by DadOfMrLog (July 25, 2013 01:13:29)

tigaire
New Scratcher
5 posts

Layering and moving off-screen

Thank you so much, DadOfMrLog! That was very helpful information and although I did realize that I need to do layering with broadcast messages, I had each sprite initialization broadcast the next message, but I like your idea of a central initialization control script would be much more clean and easy to modify if things changed.

Also, I appreciate the explanation of the rationale behind the sprite problem and the kludge to make it work anyway.

Again – thanks!
Rainbowglaze123
Scratcher
1 post

Layering and moving off-screen

I'm having that trouble also. I'm okay with it hanging at the left edge of the screen, but when I scroll right it doesn't go back to its original position.
Twicane
Scratcher
47 posts

Layering and moving off-screen

Please don't necropost. Make your own thread.
-Spectrum
Scratcher
500+ posts

Layering and moving off-screen

Reported to be closed since it was necroposted

Rainbowglaze123 wrote:

I'm having that trouble also. I'm okay with it hanging at the left edge of the screen, but when I scroll right it doesn't go back to its original position.
Please create a new topic in the future instead of posting on long-dead topics. Thanks!

Locomule
Scratcher
1000+ posts

Layering and moving off-screen

Don't close this topic as this workaround no longer works, as per DadOfMrLog's reply to Griffpatch's suggestion post..
https://scratch.mit.edu/discuss/topic/4762/?page=9

So the ancient question has been revived like a zombie boss that just won't die, is there any workaround for moving sprites off the stage completely or are we stuck with edge hangers for now?

Last edited by Locomule (Oct. 24, 2016 22:41:51)

powercon5
Scratcher
1000+ posts

Layering and moving off-screen

Locomule wrote:

Don't close this topic as this workaround no longer works, as per DadOfMrLog's reply to Griffpatch's suggestion post..
https://scratch.mit.edu/discuss/topic/4762/?page=9

So the ancient question has been revived like a zombie boss that just won't die, is there any workaround for moving sprites off the stage completely or are we stuck with edge hangers for now?
An easy workaround is
set size to (200) %
go to x: () y: (0)
set size to (100) %
I even have a project showing all the scripts and it working here
Locomule
Scratcher
1000+ posts

Layering and moving off-screen

Very interesting, thanks for sharing!

Powered by DjangoBB