Hi,
I’m using tiled maps and the cocos class Follow, for follow the main player around the map. The problem that i have is when i want to scale the tiled map. It works. But when i scale the tiled map, Follow doesn’t work anymore. Videos:
Quick fix is to just subclass Follow and fix it to cater for the scaling of the _target field, which you can see in Follow::step(float). In the video you posted, it seems to be moving the tile map while ignoring the scaling, so perhaps a fix would be:
void Follow::step(float /*dt*/)
{
if(_boundarySet)
{
// whole map fits inside a single screen, no need to modify the position - unless map boundaries are increased
if(_boundaryFullyCovered)
{
return;
}
Vec2 tempPos = _halfScreenSize - _followedNode->getPosition();
_target->setPosition(clampf(tempPos.x, _leftBoundary, _rightBoundary) * _target->getScaleX(),
clampf(tempPos.y, _bottomBoundary, _topBoundary) * _target->getScaleY());
}
else
{
_target->setPosition(_halfScreenSize - _followedNode->getPosition() * _target->getScale());
}
}
I’m simply guessing here, so that may or may not be the solution, but I’m certain that it shouldn’t be a tough issue to fix.