void PadControlLayer::onTouchesBegan(const std::vector<Touch*>& touches, Event *event) { Vec2 pt; int touchID; for ( auto &item: touches ) { auto touch = item; pt = touch->getLocation(); touchID = touch->getID(); if ( isPointInCircle(pt,kCenter,_JOYSTICK_RADIUS) ) { JoystickID = touchID; isPressed = true; this->updateVelocity(pt); } if( buttonA->boundingBox().containsPoint(pt) ) { button1ID = touchID; isButtonA = true; } if( buttonB->boundingBox().containsPoint(pt) ) { button2ID = touchID; isButtonB = true; } } }
void Joystick::onTouchesBegan(const std::vector<Touch*>& touches, Event *event) { Touch* touch = touches[0]; Vec2 touchPoint = touch->getLocation(); if (isPointInCircle(touchPoint, kCenter, JOYSTICK_RADIUS)) { isPressed = true; this->updateVelocity(touchPoint); } }
void HSJoystick::ccTouchesBegan( CCSet *pTouches, CCEvent *pEvent ) { CCTouch *touch = (CCTouch*)pTouches->anyObject(); CCPoint point = touch->locationInView(); point = convertCoordinate(point); if(isPointInCircle(point,kCenter,this->radius)) { isPressed = true; this->updateVelocity(point); } }
void Joystick::onTouchesBegan(const std::vector<Touch *> &touches, Event *event) { Touch *touch = touches[0]; Vec2 touchPoint = touch->getLocation(); if (isPointInCircle(touchPoint, _center, _joystickRadius)) { _isPressed = true; this->updateVelocity(touchPoint); } }