Jump to content

Boundaries that aren't rectangles?


Kingy

Recommended Posts

Ok I got a drag and drop item that I wish to drag within the boundaries of something.So the best thing to do I feel is to have a shape which I can drag in and it can't leave that area.However the only effective and simple method I found is something like the following.That's fine but I'm restricted to a rectangle only and is there any kind of way I can do the samething but with any polygons that I define in that kind of way?Essentially I'm aiming for a 'container' that is an irregular polygon that I can define.

ant1.onPress = function(){startDrag(this,true,161,211,325,239);}ant1.onRelease = function(){this.stopDrag();}

Link to comment
Share on other sites

Everything in Flash is a rectangle, it uses bounding boxes for everything. If you have a movie clip with a graphic that's a circle, you'll notice that when you click on that it is outlined with a rectangle, the bounding box. Collision detection and dragging and moving and sizing all use bounding boxes, you wouldn't be able to automatically define a polygon like that. You could write some custom drag code though to keep it inside a polygon, that will involve detecting the edges of the draggable object (not the bounding box) and determining if any of the edges are intersecting the boundaries of the draggable area. It's not impossible to do that but it's not the most straightfoward thing either. I'm sure there's probably something online to explain that, a guy that I work with just did something like that by following some examples in a book he has to make a game where a ball collides with objects with a playing field without relying on things like the normal hit test that just checks bounding boxes.

Link to comment
Share on other sites

Hmm I see, I had a bad ominous feeling I'd get an answer like that, thanks a lot though I'll look into it.Detecting sides as opposed to setting it in the starDrag like I did.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...