Exemplo n.º 1
0
void Widget::moveEvent()
{
    if (_touchEventCallback) {
        _touchEventCallback(this, TouchEventType::MOVED);
    }
    
    if (_touchEventListener && _touchEventSelector)
    {
        (_touchEventListener->*_touchEventSelector)(this,TOUCH_EVENT_MOVED);
    }
}
Exemplo n.º 2
0
void Widget::pushDownEvent()
{
    if (_touchEventCallback) {
        _touchEventCallback(this, TouchEventType::BEGAN);
    }
    
    if (_touchEventListener && _touchEventSelector)
    {
        (_touchEventListener->*_touchEventSelector)(this,TOUCH_EVENT_BEGAN);
    }
}
Exemplo n.º 3
0
void Joystick::onTouchEnded(Touch *pTouch, Event *pEvent)
{
    Vec2 pos = _handle->getPosition();

    if(_touchEventCallback)
        _touchEventCallback(this,0.0f,pos.x/_bgRadius,pos.y/_bgRadius,JoystickEventType::JET_TOUCH_END);

    _handle->setPosition(Vec2(0.0f,0.0f));

    _bMove = false;
}
Exemplo n.º 4
0
void Joystick::callHandleEvent(float interval)
{
    if(_bMove)
    {
        //调用摇杆事件处理方法
        Vec2 point = _handle->getPosition();

        if(_touchEventCallback)
            _touchEventCallback(this,interval,point.x/_bgRadius,point.y/_bgRadius,JoystickEventType::JET_TOUCH_MOVE);
    }
}
Exemplo n.º 5
0
void Widget::releaseUpEvent()
{
    
    if (_touchEventCallback) {
        _touchEventCallback(this, TouchEventType::ENDED);
    }
    
    if (_touchEventListener && _touchEventSelector)
    {
        (_touchEventListener->*_touchEventSelector)(this,TOUCH_EVENT_ENDED);
    }
}
Exemplo n.º 6
0
void Widget::cancelUpEvent()
{
    if (_touchEventCallback)
    {
        _touchEventCallback(this, TouchEventType::CANCELED);
    }
   
    if (_touchEventListener && _touchEventSelector)
    {
        (_touchEventListener->*_touchEventSelector)(this,TOUCH_EVENT_CANCELED);
    }
   
}
Exemplo n.º 7
0
void Widget::releaseUpEvent()
{
    this->retain();
    if (_touchEventCallback)
    {
        _touchEventCallback(this, TouchEventType::ENDED);
    }

    if (_touchEventListener && _touchEventSelector)
    {
        (_touchEventListener->*_touchEventSelector)(this,TOUCH_EVENT_ENDED);
    }

    if (_clickEventListener) {
        _clickEventListener(this);
    }
    this->release();
}
Exemplo n.º 8
0
bool Joystick::onTouchBegan(Touch *pTouch, Event *pEvent)
{
    Vec2 point = this->convertTouchToNodeSpaceAR(pTouch);

    //判断触点是否在摇杆上
    if(_touchOutsideCallback && _touchOutsideCallback(this,pTouch->getLocation()))
    {
        _bMove = true;

        setHandlePosition(pTouch->getLocation());

        point   = this->convertTouchToNodeSpaceAR(pTouch);

        Vec2 pos = _handle->getPosition();

        if(_touchEventCallback)
            _touchEventCallback(this,0.0f,pos.x/_bgRadius,pos.y/_bgRadius,JoystickEventType::JET_TOUCH_BEGIN);

        return true;
    }

    return false;
}