Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Duck Hunt Game create -> Qtimer help
Forum Updated to NodeBB v4.3 + New Features

Duck Hunt Game create -> Qtimer help

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    audrensitas
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved