当前位置: 首页>>代码示例>>C++>>正文


C++ QTimeLine::setLoopCount方法代码示例

本文整理汇总了C++中QTimeLine::setLoopCount方法的典型用法代码示例。如果您正苦于以下问题:C++ QTimeLine::setLoopCount方法的具体用法?C++ QTimeLine::setLoopCount怎么用?C++ QTimeLine::setLoopCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QTimeLine的用法示例。


在下文中一共展示了QTimeLine::setLoopCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: QGraphicsRectItem

Pong::Pong() {
    // players
    player1 = new QGraphicsRectItem(0, 0, PADDLE, PADDLE * 3);
    player1->setPos(PADDLE, (HEIGHT - PADDLE * 3) / 2);
    player1->setBrush(QBrush(Qt::gray));
    addItem(player1);
    player2 = new QGraphicsRectItem(0, 0, PADDLE, PADDLE * 3);
    player2->setPos(WIDTH - PADDLE * 2, (HEIGHT - PADDLE * 3) / 2);
    player2->setBrush(QBrush(Qt::gray));
    addItem(player2);

    // ball
    ball = new QGraphicsEllipseItem(0, 0, PADDLE, PADDLE);
    ball->setPos((WIDTH - PADDLE) / 2, (HEIGHT - PADDLE) / 2);
    ball->setBrush(QBrush(Qt::gray));
    addItem(ball);

    // score
    tscore1 = new QGraphicsSimpleTextItem();
    tscore1->setText("0");
    tscore1->setFont(QFont("Times", 36, QFont::Bold));
    tscore1->setPos(WIDTH / 2 - PADDLE - 24, PADDLE);
    tscore1->setBrush(QBrush(Qt::gray));
    addItem(tscore1);
    tscore2 = new QGraphicsSimpleTextItem();
    tscore2->setText("0");
    tscore2->setFont(QFont("Times", 36, QFont::Bold));
    tscore2->setPos(WIDTH / 2 + PADDLE, PADDLE);
    tscore2->setBrush(QBrush(Qt::gray));
    addItem(tscore2);

    // line
    int h = 0;
    int pointSize = PADDLE / 4;
    while (h < HEIGHT) {
        QGraphicsRectItem *linePoint = new QGraphicsRectItem(0, 0, pointSize, pointSize);
        linePoint->setBrush(QBrush(Qt::gray));
        linePoint->setPos((WIDTH - pointSize) / 2, h);
        addItem(linePoint);
        h += pointSize * 2;
    }

    score1 = 0;
    score2 = 0;
    dx = -1;
    dy = -1;
    speedUpCounter = 0;
    ballSpeed = 0.2;
    setSceneRect(0, 0, WIDTH, HEIGHT);
    setBackgroundBrush(QBrush(Qt::black));

    QTimeLine *timer = new QTimeLine();
    timer->setFrameRange(0, 100);
    timer->setLoopCount(10000);
    timer->start();

    connect(timer, SIGNAL(frameChanged(int)), this, SLOT(value_changed(int)));
}
开发者ID:andpei,项目名称:pong,代码行数:58,代码来源:pong.cpp

示例2: slotAddAnimationItem

void MainWindow::slotAddAnimationItem() //在场景中加入一个动画星星
{
    StartItem *item = new StartItem;
    QGraphicsItemAnimation *anim = new QGraphicsItemAnimation;
    anim->setItem(item);
    QTimeLine *timeLine = new QTimeLine(4000);
    timeLine->setCurveShape(QTimeLine::SineCurve);
    timeLine->setLoopCount(0);

    anim->setTimeLine(timeLine);

    int y =(qrand()%400)-200;
    for(int i=0; i<400; i++)
    {
        anim->setPosAt(i/400.0,QPointF(i-200,y));
    }
    timeLine->start();
    scene->addItem(item);
}
开发者ID:Pengfei-Gao,项目名称:develop-reference-data,代码行数:19,代码来源:mainwindow.cpp

示例3: QGraphicsRectItem

Pong::Pong()
{
	this->setSceneRect(0, 0, WIDTH, HEIGHT);
	this->p1 = new QGraphicsRectItem(0, 0,
					 PADDLE,
					 PADDLE*3);
	this->p2 = new QGraphicsRectItem(0, 0,
					 PADDLE,
					 PADDLE*3);

	this->p1->setPos(PADDLE, (HEIGHT-PADDLE*3)/2);
	this->p2->setPos(WIDTH-PADDLE*2, (HEIGHT-PADDLE*3)/2);
	this->p1->setBrush(QBrush(Qt::red));
	this->p2->setBrush(QBrush(Qt::blue));

	/* ball */
	this->ball = new QGraphicsEllipseItem(0, 0, PADDLE, PADDLE);
	this->ball->setPos((WIDTH-PADDLE)/2, (HEIGHT-PADDLE)/2);
	this->ball->setBrush(QBrush(Qt::black));
	
	this->setFocusItem(p1);

	this->dx = -1;
	this->dy = -1;

	QTimeLine *timer = new QTimeLine(5000);
	timer->setFrameRange(0, 100);
	
	this->addItem(ball);
	this->addItem(p1);
	this->addItem(p2);

	timer->setLoopCount(10000);
	timer->start();
	connect(timer,
		SIGNAL(frameChanged(int)),
		this,
		SLOT(value_changed(int)));
	}
开发者ID:ronghester,项目名称:movement-game,代码行数:39,代码来源:pong.cpp


注:本文中的QTimeLine::setLoopCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。