myGraphicsScene::myGraphicsScene(const int scrWidth, const int scrHeight, const int *EnCount, const int *AlCount, const int *BBCount, const int *TrCount, const qreal *spMultPerLevel, const int nLevels, const int *tPLevel, QStringList bGImageList) : myScreenWidth(scrWidth), myScreenHeight(scrHeight), myEnemyCount(EnCount), myAllyCount(AlCount), myBigBossCount(BBCount), myTrapCount(TrCount), mySpeedMultiplierPerLevel(spMultPerLevel), myNumLevels(nLevels), myCurrentLevel(0), myTimePerLevel(tPLevel), myBGImageList(bGImageList), myTotalTimeUsed(0), myTotalTrapsUsed(0), myMusicPlayer(0), myGameActive(false), myIsMinimised(false), myQmlobjectCreated(false), myGlobalMusicPause(false) { //QTimer myAdvanceTimer; QObject::connect(&myAdvanceTimer, SIGNAL(timeout()), this, SLOT(advance())); // set scene settings setSceneRect(0,0, myScreenWidth, myScreenHeight); setItemIndexMethod(QGraphicsScene::NoIndex); myView = new QGraphicsView; myView->setScene(this); myView->setFrameShape(QFrame::NoFrame); // disable frame (->true full screen) // OpenGL myView->QGraphicsView::setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers))); //QGLFormat format = QGLFormat::defaultFormat(); //format.setSampleBuffers(false); //QGLWidget *glWidget = new QGLWidget(format); //myView->QGraphicsView::setViewport(glWidget); myView->setViewportUpdateMode( QGraphicsView::FullViewportUpdate); // disable scrolling myView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); myView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // lock landscape (done in bar-descriptor) //antialiasing myView->setRenderHint(QPainter::Antialiasing); //! [4] //! [5] myView->setCacheMode(QGraphicsView::CacheBackground); //! [5] //! [6] myView->showFullScreen(); // Initialise start menu from qml myQmlengine = new QDeclarativeEngine(this); //myQmlcomponent = new QDeclarativeComponent(myQmlengine, QUrl("asset:///startMenu.qml")); // for now (ugly as ....) myQmlcomponent = new QDeclarativeComponent(myQmlengine, QUrl("app/native/assets/startMenu.qml")); // for now (ugly as ....) qDebug() << myQmlcomponent->errors(); myQmlobject = qobject_cast<QGraphicsObject *>(myQmlcomponent->create()); // change default size base on device specs myQmlobject->setProperty("width",myScreenWidth); myQmlobject->setProperty("height",myScreenHeight); addItem(myQmlobject); myQmlobjectCreated = true; // this is used in the event handler below myQmlobject->setProperty("iAmActive", true); //Connect QML signal to handler QObject::connect(myQmlobject, SIGNAL(sendQMLMessage(int, bool)), this, SLOT(signalHandler(int, bool))); // haptics QObject::connect(myQmlobject, SIGNAL(sendRumbleMessage(int)), this, SLOT(myRumbleGenerator(int))); //Connect QML exit signal to callingQuits signal (that is connected to QApplication::quit() slot in main.cpp) //QObject::connect(myQmlengine, SIGNAL(quit()), this, SIGNAL(callingQuits())); // initialise animations for startMenu.qml QObject::connect(this, SIGNAL(beginQmlAnimation()),myQmlobject, SIGNAL(beginAnimation()) ); emit beginQmlAnimation(); // connect "game finished" signals QObject::connect(this, SIGNAL(gameFinished(int, int)), myQmlobject, SIGNAL(gameFinishedQML(int, int))); // play music myMusicPlayer = new bb::multimedia::MediaPlayer(this); QUrl myUrl = QUrl("app/native/assets/music/white_winter_moon_comp.mp3"); myMusicPlayer->setSourceUrl(myUrl); myMusicPlayer->play(); QObject::connect(myMusicPlayer, SIGNAL(mediaStateChanged(bb::multimedia::MediaState::Type)), this, SLOT(startMyMusic(bb::multimedia::MediaState::Type))); // start from beginning when track ends QObject::connect(myQmlobject, SIGNAL(musicPlayPauseQML()), this, SLOT(pausePlayMyMusic())); QObject::connect(myQmlengine, SIGNAL(quit()), this, SLOT(stopMyGame())); }
void mMainOpen() { buttons_setFunc(BTN_DOWN, NULL); buttons_setFunc(BTN_UP, NULL); beginAnimation(mOpen); }
void mMainOpen() { buttons_setFuncs(NULL, menu_select, NULL); beginAnimation(mOpen); }