Exemple #1
0
CBoard::CBoard(QGraphicsScene *pScene):QGraphicsView(pScene, 0)
{
    // Members initialization
    currentScene = pScene;
    currentItem = nullptr;
    QFont fnt;
    fnt.setRawName("Helvetica");
    fnt.setPointSize(14);
    pScore = new QGraphicsTextItem();
    pScore->setDefaultTextColor(Qt::white);
    pScore->setPos(380,20);
    pScore->setFont(fnt);
    pScore->setHtml("Score: 0");
    currentScene->addItem(pScore);
    is_start = false;
    is_end = false;
    stop_move = false;
    leftBorder =  -1*currentScene->width()/2;
    rightBorder =  currentScene->width()/2;
    downBorder = currentScene->height();
    angleOfRotate = 0;
    timer = new QTimer(this);    
    connect(timer, SIGNAL(timeout()), this, SLOT(updateItemPosition()));
    boardItems.clear();
    collisionItems.clear();
    mScore = 0;
    mDelay = 0;
    mCountFigure = 0;

    //Set fixed Board size
    setFixedSize(currentScene->width(),currentScene->height());
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
}
Exemple #2
0
//! [1]
void ImageItem::hoverEnterEvent(QGraphicsSceneHoverEvent * /*event*/)
{
    timeLine.setDirection(QTimeLine::Forward);

    if (z != 1.0) {
        z = 1.0;
        updateItemPosition();
    }

    if (timeLine.state() == QTimeLine::NotRunning)
        timeLine.start();
}
Exemple #3
0
void CCLayoutTable::updateItemsPosition()
{
    if(m_pChildren && m_pChildren->count() > 0)
    {
        CCObject* child;
		int i=0;
        CCARRAY_FOREACH(m_pChildren, child)
        {
            CCNode* pNode = (CCNode*) child;
			updateItemPosition(pNode, i/m_rowMax, i%m_rowMax);
			++i;
        }
Exemple #4
0
void CCLayoutTable::addItem(CCNode* pitem, unsigned int row, unsigned int col, int tag)
{
	updateItemPosition(pitem, row, col);
	if(tag != -1)
	{
		this->addChild(pitem, 1, tag);
	}
	else
	{
		this->addChild(pitem);
	}
}
Exemple #5
0
//对生成的道具列表进行更新管理
void ItemManager::update(float dt, cocos2d::Node *render_node, IDisplayObject *pCollisionTarget)
{
    mDistanceVar += dt * COURCESPEED;
    
    updateItemPosition(dt);
    
    testCollision(render_node,pCollisionTarget);
    
    if (mDistanceVar >= ITEMDISTANCE) {
        mDistanceVar = mDistanceVar - ITEMDISTANCE;
        generateItem(render_node);
    }
}
Exemple #6
0
 ImageItem::ImageItem(int id, const QPixmap &pixmap, QGraphicsItem *parent,
                      QGraphicsScene *scene)
     : QGraphicsPixmapItem(pixmap, parent, scene)
 {
     recordId = id;
     setAcceptsHoverEvents(true);
     image = pixmap;
     timeLine.setDuration(300);
     timeLine.setFrameRange(0, 300);
     connect(&timeLine, SIGNAL(frameChanged(int)), this, SLOT(setFrame(int)));
     connect(&timeLine, SIGNAL(finished()), this, SLOT(updateItemPosition()));
     adjust();
 }