Like I have stated before here, I am trying to create a Plants vs. Zombies mod in Scratch. My main concern still seems to be attempting to create the drag-and-drop system (clicking the seed packet and then dragging and dropping it), however, the problem still seems to be the same, for example, in the editor, I can only drag the seed packet, and in preview mode, I can't drag anything.
When I have clicked the seed packet
[scratchblocks]
when this sprite clicked
Greater than or equal to ([peashooter cost v]) (100)
[/scratchblocks]
To define Greater than or equal to (var) (number)
[scratchblocks]
define Greater than or equal to (var) (number)
if <<[(var)] > [(number)]> or <[(var)] = [(number)] then
broadcast [message 1 v]
else
end
[/scratchblocks]
The code for when the seed packet sends the message to the specific plant
[scratchblocks]
when I receive [message 1 v]
create clone of [myself v]
[/scratchblocks]
The code for dragging and dropping the clone
[scratchblocks]
when I start as a clone
if <<mouse down?>> = [false]> then
forever
show
set [brightness v] effect to (40)
go to x: (mouse x) y: (mouse y)
end
else
delete this clone
end
[/scratchblocks]
Note that unlike last time, I have, in fact, initialized the cost for the Peashooter:
What am I doing wrong that would still cause the code to be like this?
When editing, scratch allows you to drag anything. To allow a sprite to be draggable whenever, go to the seneing section (light blue) and add the "set drag mode to draggable" and add it to "when flag clicked" in the sorite you want to be draggable. This will allow you to drag the sprite whenever you want. Here is how I would create a drag system, set drag mode to draggable, then, have a loop test if mouse is down, if mouse is not down it will reposition the seed packet to where it is supposed to be. That way, it is draggable, but when the player releases it it resets position.