Example #1
0
void QTELayer::onTouchesMoved(const std::vector<Touch*>& touches, Event *unused_event)
{
    if(!enableFight) return;
    Touch *touch = touches.at(0);
    Vec2 delta = touch->getDelta();
    Vec2 lastPos = touch->getPreviousLocation();
    Vec2 pos = touch->getLocation();
    
    float dx = pos.x - startTouchPosition.x;
    float dy = pos.y - startTouchPosition.y;
    float dist = sqrtf(dx*dx+dy*dy);
    
    
    streak->setPosition(pos);
    //刀的判断
    dist = pos.distanceSquared(startTouchPosition);
    
    if (dist > 50) {
        //hit test monster
        bool hit = qteMonster->hittestPoint(pos);
        if (hit) {
            hitQteMonster();
        }
    }
}