Hello all , its abit algurithem question and also cocos2d-x question
i building simple match 3 game , now inside the GEM CCSprit when used touch it and move it to the X axis i want it to move only in direct straight X line (right and left )
and when the user touch and move it in the Y axis want it to move only in direct straight Y line (up and down)
this is how i use it in the GEM class :
void Gem::ccTouchMoved(CCTouch* touch, CCEvent* event)
{
CCPoint touchPoint = touch->getLocation();
CCAssert(m_state == kPaddleStateGrabbed, "Gem - Unexpected state!");
CCLOG("Gem %s ccTouchMoved! x:%f ,y:%f",getImageName().c_str(),touchPoint.x,touchPoint.y);
if(touchPoint.x >0)
{
setPosition( ccp(touchPoint.x,getPositionY()) );
}
else if(touchPoint.y >0)
{
setPosition( ccp(getPositionX(),touchPoint.y) );
}
}
but in this code it moves only in the X axis
thanks