Physics sprite child not following parent until window is resized

Hi, I’m using Cocos2d-JS v3.6 and I’ve created a PhysicsSprite like this:

    var parent = cc.PhysicsSprite(res.cannon_base);

    var body = space.addBody(new cp.Body(10, cp.momentForBox(10, 100, 100)));
    var shape = new cp.BoxShape(body, 100, 100);

    body.setPos(cc.p(300, 300));
    parent.setBody(body);
    space.addShape(shape);

This is working ok.

But now I’ve added a child to it like this:

    var child = new cc.Sprite(res.cannon_pipe);
    child.setPosition(50, 50);
    parent.addChild(child );

And when the parent object moves in the screen (because of Chipmunk applying the laws of the physics engine to it), the child just stays in the place the parent was created and never moves. Resizing the browser window causes the child to properly be moved to where the parent is.

So, for now, I’ve cobbled together this hack as a temporary “fix”, but something like this shouldn’t be neccesary (and it’s not working when running the compiled app outside the browser):

    cc.director.getScheduler().scheduleCallbackForTarget(child, function () {
      this.setVisible(false);
      this.setVisible(true);
    }, 1 / 60, cc.REPEAT_FOREVER);

Anyone got any leads? It appears to be that this used to happen in -x up to v3.5.

Update: this also happens for packaged .apk

I solved it in this fix: https://github.com/cocos2d/cocos2d-x/pull/12239

Awesome, thanks!

Though: I’m also experiencing the bug in the Browser, so… I’ll try to see if the fix is analogous in JS code and see if I can cobble up together a solution (so I don’t have to use the ugly hack I described in my first post).