コード例 #1
0
ファイル: UIBuildingBase.cpp プロジェクト: joyfish/MyCocos2dx
void Building::unselected()
{
    this->setLocalZOrder( MAX_GRID_COUNT *_coor.y + _coor.x );
    if (_Selected)
    {
        _Selected = false;
        getArr1()->setVisible(false);
        getArr2()->setVisible(false);
        getArr3()->setVisible(false);
        getArr4()->setVisible(false);
        getBuildingArmature()->stopAction(getSharkAction());
        getBuildingArmature()->setColor(Color3B(255,255,255));
        if (_callBack)
        {
            _callBack(this);
        }
    }
    if (_isillegal)
    {
        setCoor(_orginCoor);
        setillegal(false);
    }
    if (getGrassBg())
    {
        getGrassBg()->setVisible(true);
    }
    addBuildPoint();
    if (_db && _db->coord != _coor)
    {
        _db->updateCoor(_coor.x,_coor.y);
    }

}
コード例 #2
0
OcTreeSector* RayIntersection::collideAtomicOcTreeSector(OcTreeSector* ocTreeSector)
{
    if( ocTreeSector->_triangles.size() )
    {
        // collide octree sector triangles
        Triangle* triangle;
        Vector    v0v1, v0v2, n;
        Vector    hitPoint;
        Vector    temp;
        for( unsigned int i=0; i<ocTreeSector->_triangles.size(); i++ )
        {
            triangle = _triangles + ocTreeSector->_triangles[i];
            if( ::intersectionRayTriangle(
                      &_asRay, 
                      _vertices + triangle->vertexId[0],
                      _vertices + triangle->vertexId[1],
                      _vertices + triangle->vertexId[2],
                      &hitPoint,
                      &_collisionTriangle.distance
              ))
            {
                D3DXVec3TransformCoord( &temp, _vertices + triangle->vertexId[0], &_atomic->_frame->LTM );
                _collisionTriangle.vertices[0] = wrap( temp );
                D3DXVec3TransformCoord( &temp, _vertices + triangle->vertexId[1], &_atomic->_frame->LTM );
                _collisionTriangle.vertices[1] = wrap( temp );
                D3DXVec3TransformCoord( &temp, _vertices + triangle->vertexId[2], &_atomic->_frame->LTM );
                _collisionTriangle.vertices[2] = wrap( temp );
                v0v1 = _vertices[triangle->vertexId[1]] - _vertices[triangle->vertexId[0]];
                v0v2 = _vertices[triangle->vertexId[2]] - _vertices[triangle->vertexId[0]];
                D3DXVec3Cross( &n, &v0v1, &v0v2 );
                D3DXVec3Normalize( &n, &n );
                D3DXVec3TransformNormal( &temp, &n, &_atomic->_frame->LTM );
                _collisionTriangle.normal = wrap( temp );
                D3DXVec3TransformCoord( &temp, &hitPoint, &_atomic->_frame->LTM );
                _collisionTriangle.collisionPoint = wrap( temp );
                _collisionTriangle.shader = _geometry->shader( triangle->shaderId );
                _collisionTriangle.triangleId = ocTreeSector->_triangles[i];
                if( !_callBack( &_collisionTriangle, NULL, _atomic, _callBackData ) ) return NULL;
            }
        }
    }
    else if( ocTreeSector->_subtree[0] )
    {
        for( unsigned int i=0; i<8; i++ )
        {
            if( intersectionRayAABB( &_asRay, &ocTreeSector->_subtree[i]->_boundingBox ) )
            {
                if( !collideAtomicOcTreeSector( ocTreeSector->_subtree[i] ) ) return NULL;
            }
        }
    }
    return ocTreeSector;
}
コード例 #3
0
ファイル: UIBuildingBase.cpp プロジェクト: joyfish/MyCocos2dx
void Building::selected()
{
    this->setLocalZOrder((MAX_GRID_COUNT + 1) * (MAX_GRID_COUNT + 1));
    getArr1()->setVisible(true);
    getArr2()->setVisible(true);
    getArr3()->setVisible(true);
    getArr4()->setVisible(true);
    getBuildingArmature()->runAction(getBigAction());
    _Selected = true;
    _orginCoor = getCoor();
    if (_callBack)
    {
        _callBack(this);
    }
}
コード例 #4
0
ファイル: CheckBox.cpp プロジェクト: LeeWei92/CocosGui
void CheckBox::onTouchEnded(Touch  *touch, Event  *event)
{
    if (checkParentScroll(_parentPropertyArr))
    {
        // if parent is scrolling, intercept button event
        return;
    }
    if(_enabled && !_bMoved && isVisible())
    {
        setSelected(!getSelected());
        auto hits = touchHits(touch);
        if (hits && _callBack)
        {
            _callBack(this);
        }
        //        CocosDenshion::SimpleAudioEngine::getInstance()->playEffect(Audio_Effect_Btn_Click);
    }
}