Duck Hunt Game create -> Qtimer help



  • Hello everyone.

    I try to create duck hunt game and have several questions.
    First of all i use a function to create duck object and set it in layout.

    @void CFrameWnd::SukurtiAnti()
    {

    QMovie *movie = new QMovie(":/Antis/paveiksl/duck1111.gif");
    QLabel *processLabel = new QLabel(this);
    processLabel->setMovie(movie);
    movie->start();
    ui->gridLayout->addWidget(processLabel);
    ui->gridLayout->setAlignment(Qt::AlignLeft);
    

    }@

    Secondly in constructor i have created QTimer.

    @CFrameWnd::CFrameWnd(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::CFrameWnd)

    {
    ui->setupUi(this);
    SukurtiAnti();

    QTimer *timer = new QTimer(this);
    parametras = 0;
    timer->setInterval(1/30);
    connect(timer, SIGNAL(timeout()), this, SLOT(Metodas()));
    timer->start(1000);
    

    }@

    @void CFrameWnd::Metodas()
    {
    parametras += 1;
    QMovie *movie = new QMovie(":/Antis/paveiksl/duck1111.gif");
    QLabel *processLabel = new QLabel(this);
    processLabel->setMovie(movie);
    movie->start();
    ui->gridLayout->addWidget(processLabel);
    processLabel->move(parametras,20);
    // qDebug() << parametras;

    // if(processLabel->x == 700)
    // QApplication::exit();

    // jeigu mirus y asyj krenta
    }@

    I don't know how to do better with object create and movement. First of all, if i create object in void SukurtiAnti() i don't know how to connect it with QTimer to create object, secondly if i create object in void Metodas() then Qtimer creates new duck every second, but that it is not what i need.

    I need that the duck will be created and will be moving from one point on X axis until it reach X value 700, then program should quit, but i just need to make duck movement and make it visible to my eyes .

    Any advices are appreciated.

    Cheers



  • This looks like the same discussion as "this topic":http://developer.qt.nokia.com/forums/viewthread/5443/. Closing.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.