Discuss Scratch

Neonatology
Scratcher
23 posts

In need of a better drag and drop system

At the moment I am making a scratch version of plants vs. zombies. But I have got stuck on the drag and drop system. The system I have right now looks a bit like this:
when I receive [Message v]
repeat until <mouse down?>
go to [mouse-pointer v]
end
wait until <not <mouse down?>>
go to x: ((round ((mouse x) / (55))) * (55)) y: ((round ((mouse y) / (60))) * (60))
create clone of [myself v]
However, I am wondering if there is a better system that I could incorporate into the project as this one isn't particularly accurate or easy to use. Any ideas? The project is shared, so feel free to take a peek inside: https://scratch.mit.edu/projects/304605176/editor/

Last edited by Neonatology (Aug. 14, 2019 13:03:23)


deck26
Scratcher
1000+ posts

In need of a better drag and drop system

Why not just put the go to block as it is in the repeat until? No need to go to mouse and then snap to the grid afterwards.
Neonatology
Scratcher
23 posts

In need of a better drag and drop system

I could do that, but it would mean that the clones of the sprite could be put anywhere on the screen, but I want the player to only be able to place the clones on the squares of grass.

Last edited by Neonatology (Aug. 14, 2019 17:08:40)


deck26
Scratcher
1000+ posts

In need of a better drag and drop system

Neonatology wrote:

I could do that, but it would mean that the clones of the sprite could be put anywhere on the screen, but I want the player to only be able to place the clones on the squares of grass.
Why does it mean that? You copy the same x and y information from the current go to block so the snap to grid is working at all times.

I suggest not putting an image in your post as it will either make the topic longer to scroll through or those responding need to remove it.

Last edited by deck26 (Aug. 14, 2019 16:00:33)

Neonatology
Scratcher
23 posts

In need of a better drag and drop system

Thanks, working now, I think I misunderstood you before. Thanks again!

Powered by DjangoBB

Standard | Mobile