How to Drag-n-Drop Circle object to a Circle Target

CulturePlayCulturePlay Member, PRO Posts: 113
edited May 2012 in Working with GS (Mac)
Ok, I'm working on a new math game and I need some help with the drag and drop system I am trying to build.

I have multiple draggable circle-shaped actors on the scene. Each of these drag-circles has a corresponding circular target area. The target-circles are organized on the scene to form a pyramid shape (eventually will have different shapes on other levels). I would like to program the game in a way that when the drag-circle moves close to the target-circle it snaps into place, otherwise on release it snaps back to it's original position.

I've looked at several videos on drag-n-drop, but I don't think they cover snapping to target or back to original position. And I don't believe they cover dragging and snapping to a circular target.

Thanks folks!

Best Answer

  • MarkOnTheIronMarkOnTheIron Posts: 1,447
    Accepted Answer
    Ok, now I understand your problem.

    It has nothing to do with the shape of the objects and targets. The problem here is with the shape of you imaginary grid that is triangular. Unfortunately my system is not applicable to your case. The only way I could see it done is by using tables were you put the coordinates of every target and then using trigger actors in your pyramid you can use the data in the table to snap the object in the target.


Answers

  • MarkOnTheIronMarkOnTheIron Member Posts: 1,447
    edited May 2012
    I made this a while ago. Maybe it may help you. It is based on an old FMG template.

    http://dl.dropbox.com/u/8244920/Snap_to_grid_demo.zip


  • CulturePlayCulturePlay Member, PRO Posts: 113
    @MarkOnTheIron thanks yes this definitely helps me! However my main issue is working with circular shapes. I see that you use the constrain behavior to lock the actor's X & Y position to the mouses position every N# of pixels. This method seems to force a rectangular/square region.
    I'm still having trouble working with locking a circle object into a circle target.

    best!
  • MarkOnTheIronMarkOnTheIron Member Posts: 1,447
    It constraint the items to the center of the shape so if in my demo you substitute the rounded rectangle shape with circle shape it will work the same.



  • CulturePlayCulturePlay Member, PRO Posts: 113
    @MarkOnTheIron take a look at what I am trying to accomplish:

    http://dl.dropbox.com/u/15397573/pyramid.zip

    If I could get the drag-circles to snap into the target-circles on the pyramid and snap back to their original positions...I think I can figure out the snapping back to original positions part of the program. Using the grid method in your demo, looks like I need to define a rectangular region as target area, but what if my region is a triangular pyramid or diamond shaped. I wouldn't want the snap to grid effect to be active if the user is outside of the grid area of the shape.

    best.
  • CulturePlayCulturePlay Member, PRO Posts: 113
    @MarkOnTheIron thanks! I will give the tables idea a shot. Thanks!
Sign In or Register to comment.