When I touch, I store the position as CCPoint object. Then, I get x and y of the CCPoint I store, it’s different. I printed the value x and y, they’re different. Can anybody explain for me? Thanks
My code
void GameplayScene::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent){
CCSetIterator iter = pTouches->begin();
for (; iter != pTouches->end(); iter++)
{
if (isShooting == false){
CCTouch* pTouch = (CCTouch*)(*iter);
touchPos = pTouch->getLocation(); //touchPos is CCPoint object which is declare in GameplayScene.h as public
CCLog("BEGAN X= %d", touchPos.x);
CCLog("BEGAN Y= %d", touchPos.y);
isShooting = true;
}
}
}
void GameplayScene::ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent)
{
CCSetIterator iter = pTouches->begin();
for (; iter != pTouches->end(); iter++)
{
CCTouch* pTouch = (CCTouch*)(*iter);
CCPoint touchEndPos = pTouch->getLocation();
CCLog("ENDDDDDD X= %d", touchPos.x);
CCLog("ENDDDDDD Y= %d", touchPos.y);
if (touchEndPos.x == touchPos.x&& touchEndPos.y == touchPos.y){
isShooting = false;
}
}
}