Phil Ciraolo
Phil Ciraolo

Reputation: 37

Flutter Flame Dropped On

Using Flutter with Flame and trying to determine what Component is dropped on during a drag operation. For example, dragging a SpriteComponent works great but when I drop the component I can't seem to find any event or way of determining what component was dropped on. Right now I keep a List of all Components placed in the game and iterate through this list to find the closest component comparing the x and Y values with the Dropped x and Y . This is not as accurate as I need and I'm looking for a better way of accomplishing this. Flutter itself has the DragTarget widget but I don't believe we can use that in Flame.

Anyone have a better way of doing this?

Upvotes: 0

Views: 166

Answers (1)

spydon
spydon

Reputation: 11512

You can use collision detection for that, and make sure that your hitboxes are set to isSolid = true if your component can be dropped fully enclosed by another component.

Meanwhile the component is being dragged you can set the hitboxes collisionType to CollisionType.inactive so that it doesn't react to collisions, and then on the end event your set it to active again.

Upvotes: 0

Related Questions