setPosition() with and without arrow notation in same block

setPosition() with and without arrow notation in same block
0

this code block accessing setPosition method by using this-> but next lines same method doesnt use this-> notation. Does both same calling inherited cocos2d::Sprite member? (code from …cocos2d-x-3.16\tests\cpp-tests\Classes\TouchesTest\Ball.cpp)

void Ball::move(float delta)
{
    this->setPosition(getPosition() + _velocity * delta);

    if (getPosition().x > VisibleRect::right().x - radius()) 
    {
        setPosition(VisibleRect::right().x - radius(), getPosition().y);
        _velocity.x *= -1;
    } 
    else if (getPosition().x < VisibleRect::left().x + radius()) 
    {
        setPosition(VisibleRect::left().x + radius(), getPosition().y);
        _velocity.x *= -1;
    }
}

Hi. Yes. this-> is a pointer for ball class.

Thank you.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.