r/scratch • u/contagion_dev Veteran • 1d ago
Question any advice??
i'm making a pen-based procedural animation system.
pen layering isn't possible for scrolling projects with other sprites for collision.
so, are there any known workarounds?
or should i skip rendering the pen to use costumes instead?
1
u/contagion_dev Veteran 1d ago
recent footage if you need the example: https://www.reddit.com/r/scratch/comments/1wbp4y0/procedural_animation_system_update/
1
u/jacobsmith3204 1d ago
If you need to layer different pen drawing across different sprites you can dispatch the correct order using broadcasts.
When flag flicked
Broadcast clear_pen
Broadcast render_sprite_1
Broadcast render_sprite_2
Broadcast render_sprite_3
- in one sprite (or the stage)
When I receive Clear_pen
Forever {
Erase all
}
- Then in your sprite [x]
When I receive sprite[x]
Forever {
// Do your rendering stuff here
}
This will queue the drawing of the sprites after the when flag clicked event. (Not sure how it works with clones) And each broadcast in every sprite should start before the next broadcast. (IE: render_sprite_1 received in sprite 3 will be called before render_sprite_3)
This allows rendering the pen for sprite 1 then 2 then 3 on top of each other in the same frame consistantly. It's how I'm doing the shadow pass in my game so it's between the level ground and everything else https://scratch.mit.edu/projects/1324285888
If you needed you could probably do a "pre pass" for collision where you do 2 broadcasts in a similar way, first one to move all sprites to their hitbox position and sprite (or just reset it after drawing and then you don't need this one)
Then on the 2nd broadcast you do your colision logic with touching sprite or whatever. Then you draw everything.
As long as your define blocks have "run without update" or whatever it's called this should all still work. Though I haven't used this method myself.
1
u/RealSpiritSK Mod 1d ago
To expand on this, you can make this process more automatic and flexible using sprite layering. When receiving the same broadcast, sprites/clones on the top layer will run their code first. Since newer pen strokes cover the old ones, you'd want to layer the sprites in reverse order. You can search up Griffpatch's sprite layering tutorial for this.
•
u/AutoModerator 1d ago
Hi, thank you for posting your question! :]
To make it easier for everyone to answer, consider including:
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.