How i made the pvz plant system?

Since my last post, everything has been going well with my pvz fangame, now i need to make that thing of picking the plant from the seed display to the garden. How i do that?

Just add the draggable behavior or do some event so when your mouse is over plant icon set the position of plant icon to MouseX(),MouseY()
then check if plant card is in collision with any of the first squares on the vertical line and if Mouse released then set plant card to hud position and create a new plant in the collided square.


i made this code and now i just need some things: how to make that i can’t plant a plant where there is already a plant.

If mouse released and plant is not planted in block then
Plant plant

add a variable to plantcheck like bool. variable occupied set to false if no plant is in collision with, and true if a plant is in collision with plantcheck set variable to true.
so later when you try to place another plant in an occupied plantcheck do not let that happen.

Like:
if sf_seedsplay is in collision with plantcheck
plantcheck occupied = false
left mouse released
Here yes can be placed

if sf_seedsplay is in collision with plantcheck
plantcheck occupied = true
left mouse released
Here yes can’t be placed


hey there, well i don’t know why but when i plant 2 plant(1 on the top and other at the bottom) i can’t plant in the middle and when i plant in the middle i cant plant at top or bottom, pls tell me what i did wrong.

You can try something like this

The GridLine used for the very first vertical line

The Human Card with draggable

i tried this, but now i can’t plant more than other one plant, how fix