It took me more than 4 hours to solve the problem. I really hope AppGameKit can support zooming by offset.
Now when set view offset, and zoom view by centre mode, the view will move at first, the black screen will appear, and then zoom in. It looks strange. Then I think it over and over, and got a solution finally.
As the following shows, I zoom the view as while as moving the view.
m_fScale+=0.1;
agk::SetViewZoom(m_fScale);
SetViewOffset(m_fScale);
if (m_fScale>=2.0) {
m_fScale = 2.0;
m_bScale = false;
m_bSetPosition = true;
m_bZooming=true;
}
void CChess::SetViewOffset(float fScale)
{
float fSpeedX=m_iWinWidth/4;
float fSpeedY=m_iWinHeight/4;
if (m_fX>m_iWinWidth/4*3) {
}else if(m_fX<m_iWinWidth/4){
fSpeedX=-fSpeedX;
}else {
fSpeedX=m_fX-m_iWinWidth/2;
}
if (m_fY>m_iWinHeight/4*3) {
}else if (m_fY<m_iWinHeight/4){
fSpeedY=-fSpeedY;
}else {
fSpeedY=m_fY-m_iWinHeight/2;
}
agk::SetViewOffset(fSpeedX*(fScale-1), fSpeedY*(fScale-1));
}
The Miracrea Games