Search code examples
drag-and-dropmit-scratchblock-programming

How can I fix my drag-and-drop system in Scratch to work properly for my Plants v.s Zombies mod?


Like I have stated here, I am trying to create a Plants v.s Zombies mod in Scratch. However, the main issue still seems to be that the drag and drop system just does not seem to want to work. (This would be clicking the seed packet and then dropping it where it needs to be dropped.) The problem is, it seems to be working now, but only other than the fact that this happens:

It doesn't work. All it seems to do is make a clone of the plant, and nothing else.


Note: I have already stated the rest of the code in my previous question, and nothing seems to be wrong with that, so that is why I am only mentioning the code to create the drag and drop system

The code that I use to create the drag-and-drop system


Sending the message when sprite is clicked

[scratchblocks]
when I receive [message 1 v]
create clone of [myself v]
[/scratchblocks]

The code when the sprite starts as a clone:


[scratchblocks]
when I start as clone
show
set [brightness v] effect to (40)
switch costume to [costume 2 v]
set drag mode [draggable v] :: sensing
go to x: (mouse x) y: (mouse y)
forever
if <[<mouse down?>] = [1]> then
wait until <>
forever
go to x: (mouse x) y: (mouse y)
end
else
delete this clone
end
end

enter image description here

However, it doesn't seem to be working. Why would the code be like this?


Solution

  • I think you need to remove the second forever so that you can drop the plant, because right now it just goes to the mouse position forever. Also, if the sprite is not on your mouse, you should check that the image of the plant is centered