Skip to main content
Inspiring
June 19, 2012
Question

AS3 - iOS, drag and drop collision

  • June 19, 2012
  • 2 replies
  • 1705 views

Hi,

I'm using Flash Pro/ Actionscript 3 for an iOS-game.

I've used this site: http://www.designscripting.com/2011/05/hittest-as3-for-collision-detection-flash-actionscript-3/ and this picture to demonstrate my question. When using 'drag and drop' is it possible to e.g. move through a maze and not go through the walls? Like stopDrag if the blueobject hits it? I can make this work with a virtual joystick (or they keys on a computer), but I wanted to use the touch-function on the iPhone. I was hoping this could be done withouth a physic-engine.

This topic has been closed for replies.

2 replies

Mark.fromOP
Inspiring
June 21, 2012

I found this video helpful when I was researching collisions.

http://www.youtube.com/watch?v=iUbX9tFtqTg

You can probably do a stopTouchDrag when your dragged object intersects a wall which could be on an array list. Or you can kill the object when the two cross, depends on what you are doing.

One suggestion is to offset the dragged object from the place where the finger is touching because it would make it impossible to see what the user is dragging if their finger is covering it up.

User Unknow
Legend
June 19, 2012

Do this with simple MouseEvent.MOUSE_UP, MouseEvent.MOUSE_DOWN, MouseEvent.MOUSE_MOVE or instead MouseEvent.MOUSE_MOVE use Event.ENTER_FRAME and get stage.mouseX / stage.mouseY

Does not matter iOS or Web or Standalone app. You need do drag&drop.