Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to make draggable items snap back to where it was before being dragged
- OtakuFurryAlphaGamer
- Scratcher
3 posts
How to make draggable items snap back to where it was before being dragged
I'm creating an inventory system based off of “Don't Escape” and I'm having an issue. I want to be able to take and move around an item - and if the item isn't touching something it can combine with it goes back to where it was in the inventory. Does anyone know how to achieve this?
- yadayadayadagoodbye
- Scratcher
1000+ posts
How to make draggable items snap back to where it was before being dragged
Save the previous slot index/x and y value (depending on how you do slots) into a (or 2) variables, check when the sprite is released to see if its not touching anything, if not, put it back into the slot based on the index/x and y value which you previously saved.
- MineTurte
- Scratcher
500+ posts
How to make draggable items snap back to where it was before being dragged
Isn't there a way that's even more optimized though? Idk I kinda forgot but I'm Save the previous slot index/x and y value (depending on how you do slots) into a (or 2) variables, check when the sprite is released to see if its not touching anything, if not, put it back into the slot based on the index/x and y value which you previously saved.pretty sure there is…
also I would be responding on @Juni-Bug but apparently new scratchers can't talk on the forum! hints why I am currently speed running getting scratcher
Last edited by MineTurte (March 21, 2024 17:47:43)
she/her
Front-end web developer and software programmer
Javascript, HTML5, CSS, Python3, & Lua.
Signature color gradients here
cool LiDAR game!
AAGS Manager
- yadayadayadagoodbye
- Scratcher
1000+ posts
How to make draggable items snap back to where it was before being dragged
pretty sure there is…I don't see how that is unoptimized, you're only saving 2 values into variables, thats an O(1) operation Isn't there a way that's even more optimized though? Idk I kinda forgot but I'm
and it only takes up O(1) memory as well
Last edited by yadayadayadagoodbye (March 21, 2024 17:52:19)
- MineTurte
- Scratcher
500+ posts
How to make draggable items snap back to where it was before being dragged
It is optimized but what I'm saying is I could've sworn I remember seeing a way to do that but even simpler, but idk lol. Maybe I'm thinking of something else?pretty sure there is…I don't see how that is unoptimized, you're only saving 2 values into variables, thats an O(1) operation Isn't there a way that's even more optimized though? Idk I kinda forgot but I'm
and it only takes up O(1) memory as well
she/her
Front-end web developer and software programmer
Javascript, HTML5, CSS, Python3, & Lua.
Signature color gradients here
cool LiDAR game!
AAGS Manager
- OtakuFurryAlphaGamer
- Scratcher
3 posts
How to make draggable items snap back to where it was before being dragged
Save the previous slot index/x and y value (depending on how you do slots) into a (or 2) variables, check when the sprite is released to see if its not touching anything, if not, put it back into the slot based on the index/x and y value which you previously saved.
Could you be a litte more specific? Sorry, its really complicated. I partially followed a tutorial named “How to make an UPGRADED INVENTORY system in Scratch - Tutorial”, rest is stuff I added.
I've added and removed a bunch of things, but nothing works. Heres what I have so far: https://scratch.mit.edu/projects/984367892/
- OtakuFurryAlphaGamer
- Scratcher
3 posts
How to make draggable items snap back to where it was before being dragged
Save the previous slot index/x and y value (depending on how you do slots) into a (or 2) variables, check when the sprite is released to see if its not touching anything, if not, put it back into the slot based on the index/x and y value which you previously saved.
Hey, i've been trying a few things out but im still a little confused. It's hard since theres an animation for the inventory that plays.
- Discussion Forums
- » Help with Scripts
- » How to make draggable items snap back to where it was before being dragged