Trouble getting a physics body using touch events on ipad

Hi,

I created a touch and drag object demo using cocos2dx with javascript bindings. It works fine on the browser and the ipad simulator , but it does not return the polyshape or body under the touch point when running on the iPad. The function space.pointQueryFirst() always returns shape which is invalid. If you call any function on this returned value like getBody() or getBB() it crashes.

Again this issue happens only when running on the iOS device and not on the simulator or the browser.

These are my touch events.

onTouchesBegan:function (pTouch,pEvent){

    self.mouse = this.touch2point(pTouch[0].getLocation().x, pTouch[0].getLocation().y);
    this.mouseBody.p = this.touch2point(pTouch[0].getLocation().x, pTouch[0].getLocation().y);

    if(!self.mouseJoint) {
        var point = this.touch2point(pTouch[0].getLocation().x, pTouch[0].getLocation().y);
        var shape = this.space.pointQueryFirst(point, GRABABLE_MASK_BIT, cp.NO_GROUP);
         // -- THIS IS WHERE IT BREAKS -- 
        if(shape){
            var body = shape.body; 
            var mouseJoint = self.mouseJoint = new cp.PivotJoint(this.mouseBody, body, this.touch2point(pTouch[0].getLocation().x, pTouch[0].getLocation().y));

            mouseJoint.maxForce = 50000;
            mouseJoint.errorBias = Math.pow(1 - 0.15, 60);
            this.space.addConstraint(mouseJoint);
        }
    }
}

onTouchesEnded:function (pTouch,e){

    self.mouse = this.touch2point(pTouch[0].getLocation().x, pTouch[0].getLocation().y);
    if(self.mouseJoint) {
        this.space.removeConstraint(self.mouseJoint);
        self.mouseJoint = null;
    }

}

onTouchesMoved:function(pTouch,e){

    self.mouse = this.touch2point(pTouch[0].getLocation().x, pTouch[0].getLocation().y);
    var newPoint = v.lerp(this.mouseBody.p, self.mouse, 0.25);
    this.mouseBody.v = v.mult(v.sub(newPoint, this.mouseBody.p), 60);
    //this.mouseBody.p = cc.p(newPoint.x,140);
    this.mouseBody.p = newPoint;

}

Has anyone encountered this issue ?

I have created a chipmunk test xcode project using cocos2d-x . Here’s a link to the xcode project. https://www.dropbox.com/s/jjd62ban9z7hnsa/SimpleChipmunkBoxTest.zip

It looks like the issue definitely is with the function pointQueryFirst which is not able to return a valid shape object.

Any help appreciated.

Thanks

Amit

in this thread http://www.cocos2d-x.org/boards/20/topics/25430 in the last post there is another with this issue explaing that for him worked on ios simulator but not on device.
Probably is a bug? :frowning: