Example #1
0
InetAddress * InetAddressSet::removeElement(const InetAddress &key){
	long position=getPositionIndex(key);
	if(position==-1){
		return 0;
	}else{
		return removeElementAt(position);
	}
}
Example #2
0
//ボール落下アニメーション
void BallSprite::fallingAnimation(int maxRemovedNo)
{
    if (_fallCount > 0)
    {
        setPositionIndex(PositionIndex(_positionIndex.x,
                                       _positionIndex.y - _fallCount));
        auto delay = DelayTime::create(ONE_ACTION_TIME * maxRemovedNo);
        auto show = Show::create();
        auto move = MoveTo::create(ONE_ACTION_TIME,
                                   getPositionForPositionIndex(getPositionIndex()));
        runAction(Sequence::create(delay, show, move, nullptr));
    }
}
void GameLayer::onTouchMoved(Touch* touch, Event* unused_event)
{
    //スワイプとともにボールを移動する
    _movingBall->setPosition(_movingBall->getPosition() + touch->getDelta());
    
    auto touchBall = getTouchBall(touch->getLocation(), _movingBall->getPositionIndex());
    if (touchBall && _movingBall != touchBall)
    {
        //移動しているボールが、別のボールの位置に移動
        _movedBall = true;
        
        //別のボールの位置インデックスを取得
        auto touchBallPositionIndex = touchBall->getPositionIndex();
        
        //別のボールを移動しているボールの元の位置へ移動する
        touchBall->setPositionIndexAndChangePosition(_movingBall->getPositionIndex());
        
        //移動しているボールの情報を変更
        _movingBall->setPositionIndex(touchBallPositionIndex);
    }
}
/*! The increment operator steps the iterator to the next face. If it is
    already beyond the last face it does not change.
    
    \dev This is the central function of the whole iterator. It changes 
    _facePntIndex to contain the data for the next face, depending on the type
    of the currently active primitive and steps to the next primitive if the
    current one is exhausted. The only tricky part is the left/right swap for
    triangle strips, the rest is pretty simple. \enddev
*/
void FaceIterator::operator++()
{
    // already at end?
    if(isAtEnd())
        return;
    
    ++_faceIndex;

    // at end of primitive?
    if(_actPrimIndex >= PrimitiveIterator::getLength())
    {
        ++(static_cast<PrimitiveIterator&>(*this));
        
        startPrim();
        
        return;
    }

    switch(getType())
    {
    case GL_TRIANGLES:      _facePntIndex[0] = _actPrimIndex++;
                            _facePntIndex[1] = _actPrimIndex++;
                            _facePntIndex[2] = _actPrimIndex++;
                            _facePntIndex[3] = -1;
                            break;
    case GL_QUAD_STRIP:     _facePntIndex[0] = _facePntIndex[3];
                            _facePntIndex[1] = _facePntIndex[2];
                            _facePntIndex[3] = _actPrimIndex++;
                            _facePntIndex[2] = _actPrimIndex++;
                            break;
    case GL_TRIANGLE_STRIP: if(_actPrimIndex & 1)
                            {
                                _facePntIndex[0] = _facePntIndex[2];
                            }
                            else
                            {
                                _facePntIndex[1] = _facePntIndex[2];
                            }                           
                            _facePntIndex[2] = _actPrimIndex++;
                            
                            if(getPositionIndex(0) == getPositionIndex(1) ||
                               getPositionIndex(0) == getPositionIndex(2) ||
                               getPositionIndex(1) == getPositionIndex(2))
                            {
                                --_faceIndex;
                                ++(*this);
                            }
                               
                            break;
    case GL_POLYGON:
    case GL_TRIANGLE_FAN:   _facePntIndex[1] = _facePntIndex[2];
                            _facePntIndex[2] = _actPrimIndex++;
                            break;
    case GL_QUADS:          _facePntIndex[0] = _actPrimIndex++;
                            _facePntIndex[1] = _actPrimIndex++;
                            _facePntIndex[2] = _actPrimIndex++;
                            _facePntIndex[3] = _actPrimIndex++;
                            break;
    default:                SWARNING << "FaceIterator::++: encountered " 
                                      << "unknown primitive type " 
                                      << getType()
                                      << ", ignoring!" << std::endl;
                            startPrim();
                            break;
    }           
}
Example #5
0
bool InetAddressSet::contains(const InetAddress &keyAddr)const{
	return getPositionIndex(keyAddr)!=-1;
}