cocos2d / cocos2d-x

Cocos2d-x is a suite of open-source, cross-platform, game-development tools utilized by millions of developers across the globe. Its core has evolved to serve as the foundation for Cocos Creator 1.x & 2.x.
https://www.cocos.com/en/cocos2d-x
18.24k stars 7.06k forks source link

Node::updateTransformFromPhysics is not working correctly with Follow action #11743

Open smoke91 opened 9 years ago

smoke91 commented 9 years ago

As in title.

I added log to updateTransformFromPhysics method:

    recordedPosition = newPosition;
    Vec3 vec3(newPosition.x, newPosition.y, 0);
    Vec3 ret;
    parentTransform.getInversed().transformPoint(vec3, &ret);
    if (this->getTag() == 666)
    {
        CCLOG("SETTING POSITION = (%f : %f)", ret.x, ret.y);
    }
    setPosition(ret.x, ret.y);

and move Armature with physics body along the X axis. When the object reach half of the screen and Follow action change position of Armature parent updateTransformFromPhysics method print this output:

SETTING POSITION = (1266.674438 : 339.923553) // CORRECT SETTING POSITION = (1273.812378 : 339.923553) // CORRECT SETTING POSITION = (1280.429565 : 339.923553) // CORRECT SETTING POSITION = (1287.463135 : 339.923553) // CORRECT SETTING POSITION = (1308.250610 : 339.923553) // INCORRECT SETTING POSITION = (1356.958374 : 339.923553) // INCORRECT SETTING POSITION = (1461.065918 : 339.923553) // INCORRECT SETTING POSITION = (1678.051392 : 339.923553) // INCORRECT SETTING POSITION = (2116.099609 : 339.923553) // INCORRECT SETTING POSITION = (2999.391113 : 339.923553) // INCORRECT SETTING POSITION = (4772.568848 : 339.923553) // INCORRECT SETTING POSITION = (8324.978516 : 339.923553) // INCORRECT SETTING POSITION = (15448.297852 : 339.923553) // INCORRECT

Cocos2d-x version: >= 3.5

Repetition rate: 100%

smoke91 commented 9 years ago

Workaround: i've added armature to transparent layer and layer to scene, now it's working workaround works also for: #11745