Old code using m_tPosition , what the replacement for this?

Hello all
i have some old code that is using some previuse cocos2d-x version , i try to upgread the code i have to the newer version
but i get compilation error :
this is the function i have :

`void Terrain::move (float xMove) {

if (xMove < 0) return;


if (_startTerrain) {

    if (xMove > 0 && _gapSize < 5) _increaseGapTimer += xMove;

    if (_increaseGapTimer > _increaseGapInterval) {
        _increaseGapTimer = 0;
        _gapSize += 1;
    }
}

this->setPositionX(this->getPositionX() - xMove);

Block * block;
block = (Block *) _blocks->objectAtIndex(0);

if (m_tPosition.x + block->getWidth() < 0) {

    _blocks->removeObjectAtIndex(0);
    _blocks->addObject(block);

    m_tPosition.x +=  block->getWidth();

    float width_cnt = this->getWidth() - block->getWidth() - ((Block *) _blocks->objectAtIndex(0))->getWidth();
    this->initBlock(block);
    this->addBlocks(width_cnt);
}

}`

im getting this compilation error :

1> Terrain.cpp 1>d:\dev\cpp\cocos2d-x\cocos2d-2.1rc0-x-2.1.3\cocos2d-2.1rc0-x-2.1.3\victorianrushhour\classes\terrain.cpp(188): error C2065: 'm_tPosition' : undeclared identifier 1>d:\dev\cpp\cocos2d-x\cocos2d-2.1rc0-x-2.1.3\cocos2d-2.1rc0-x-2.1.3\victorianrushhour\classes\terrain.cpp(188): error C2228: left of '.x' must have class/struct/union 1> type is ''unknown-type'' 1>d:\dev\cpp\cocos2d-x\cocos2d-2.1rc0-x-2.1.3\cocos2d-2.1rc0-x-2.1.3\victorianrushhour\classes\terrain.cpp(193): error C2065: 'm_tPosition' : undeclared identifier 1>d:\dev\cpp\cocos2d-x\cocos2d-2.1rc0-x-2.1.3\cocos2d-2.1rc0-x-2.1.3\victorianrushhour\classes\terrain.cpp(193): error C2228: left of '.x' must have class/struct/union 1> type is ''unknown-type''
>

i can see that there is instance in CCPlace class , but when i include the #include “actions\CCActionInstant.h” it doesn’t help .
how can i post it ?

1 Like

The solution to whom is also face this , is to use :
CCPoint m_obPosition;

for 3.0 use:
_position
from Place class

[+] Cocos2d-x V2.x :
CCPoint m_obPosition;
CCSize m_obContentSize;
[+] Cocos2d-x V3.x :
Vec2 __position; (replace : m_obPosition -> _position)
Size __contentSize;(replace:m_obContentSize->_contentSize)
…v…v…

1 Like