Skip to main content
October 27, 2012
Question

stopTouchDrag problem

  • October 27, 2012
  • 2 replies
  • 809 views

I made a nice game for ios which includes stopTouchDrag.

In the game there are many squares very close to each other on stage and user drags and drops items on them.

The code indicates that if items hittest squares it sticks to their x, y - else, the items dissapear.

When i sumulate the game it works perfect, however when i test it on iphone device it happens sometimes that if the stopTouchDrag of the items

is not exactly on squares it neither sticks to the square and nor dissapear - but remains "inbetween" squares (this doesnt happen when i test and simulate it on my desktop)

can some one tell me how to solve problem?

This topic has been closed for replies.

2 replies

Mark.fromOP
Inspiring
October 28, 2012

Sounds like something is in the way, so you never trully release but the touch just gets broken up by an in between object.

What is your stopTouchDrag assigned to, is it to that object? If so try assigning it to the stage. Also how are you listening for the stopTouchDrag, is it on TOUCH_END? if so try adding a TOUCH_OUT event as well.

October 30, 2012

thank you

i tried to change to TOUCH_OUT but it doesnt work

this is part of my my code:

if i have only 8 big squares on stage it works ok. the problem is when there are 36  targets on stage (squares are small).

i remind you than when simulating it works perfect - problem is on iphone device.

function end_s(event:TouchEvent):void

{

 

                    event.target.stopTouchDrag(event.touchPointID);

                    var targets_16;

                    var obj_16 = event.target;

                    event.target.stopTouchDrag(event.touchPointID);

                    targets_16=(obj_16.dropTarget.parent)

 

                    //if hits the free squares - sticks to them

                    if(obj_16.hitTestObject(ma1)||obj_16.hitTestObject(ma4)||obj_16.hitTestObject(ma5)||obj_16.hitTestObject(ma6)

               ||obj_16.hitTestObject(mb1)||obj_16.hitTestObject(mb2)||obj_16.hitTestObject(mb3)||obj_16.hitTestObject(mb4)||obj_16.hitTestObject(mb6)

               ||obj_16.hitTestObject(mc1)||obj_16.hitTestObject(mc5)||obj_16.hitTestObject(mc6)

               ||obj_16.hitTestObject(md2)|obj_16.hitTestObject(md4)

                     ||obj_16.hitTestObject(me2)||obj_16.hitTestObject(me3)||obj_16.hitTestObject(me4)

               ||obj_16.hitTestObject(mf2)||obj_16.hitTestObject(mf3)||obj_16.hitTestObject(mf4)||obj_16.hitTestObject(mf6))

                    {

                      obj_16.x=targets_16.x

                    obj_16.y=targets_16.y

                      my_sound_s.play();

                      trace(s_placex);

             }

             else{

                        obj_16.x=s_placex;

                              obj_16.y=760;

                                 trace(targets_16.name);

            }