S2DB::S2DB( QWidget *p ) : QFrame( p ) { setupUi( this ); Read = false; CBar->setAutoScale( AutoScaleB->isChecked() ); S2DV->setCBar( CBar ); MCAsDirSel = new QFileDialog; MCAsDirSel->setAcceptMode( QFileDialog::AcceptOpen ); MCAsDirSel->setDirectory( QDir::currentPath() ); qDebug() << "Cur Path" << QDir::currentPath(); MCAsDirSel->setNameFilter( "*" ); MCAsDirSel->setFileMode( QFileDialog::Directory ); MCAsDirSel->setConfirmOverwrite( false ); PopDialog = new QDialog; PopDialog->resize( 600, 400 ); QGridLayout *bl = new QGridLayout; PopDialog->setLayout( bl ); popping = false; layout = NULL; connect( PopDialog, SIGNAL( finished(int) ), this, SLOT( PopUp() ), Qt::UniqueConnection ); connect( PopB, SIGNAL( clicked() ), this, SLOT( PopUp() ), Qt::UniqueConnection ); connect( LoadMCAsB, SIGNAL( clicked() ), MCAsDirSel, SLOT( show() ), Qt::UniqueConnection ); connect( MCAsDirSel, SIGNAL( fileSelected( const QString & ) ), this, SLOT( LoadMCAs( const QString & ) ), Qt::UniqueConnection ); #if 0 connect( S2DPopUp, SIGNAL( clicked() ), this, SIGNAL( popup() ), Qt::UniqueConnection ); connect( S2DPrintB, SIGNAL( clicked() ), this, SIGNAL( print() ), Qt::UniqueConnection ); #endif connect( AutoScaleB, SIGNAL( toggled( bool ) ), CBar, SLOT( setAutoScale( bool ) ), Qt::UniqueConnection ); connect( zmax, SIGNAL( editingFinished() ), this, SLOT( newInputZmax() ), Qt::UniqueConnection ); connect( zmin, SIGNAL( editingFinished() ), this, SLOT( newInputZmin() ), Qt::UniqueConnection ); connect( S2DV, SIGNAL( newAutoZmax( double ) ), CBar, SLOT( newAutoZmax( double ) ), Qt::UniqueConnection ); connect( S2DV, SIGNAL( newAutoZmin( double ) ), CBar, SLOT( newAutoZmin( double ) ), Qt::UniqueConnection ); connect( CBar, SIGNAL( newZZ( QString, QString ) ), this, SLOT( newZZ( QString, QString ) ), Qt::UniqueConnection ); connect( CBar, SIGNAL( newScale() ), S2DV, SLOT( update() ), Qt::UniqueConnection ); mapLoadTimer = new QTimer; connect( mapLoadTimer, SIGNAL( timeout() ), this, SLOT( loadNextMap() ), Qt::UniqueConnection ); loadingMCAMap = false; loadingAMCA = false; mapSaveTimer = new QTimer; connect( mapSaveTimer, SIGNAL( timeout() ), this, SLOT( saveNextMap() ), Qt::UniqueConnection ); savingMCAMap = false; savingAMCA = false; }
//load加载整个背景 void MyPlayLayer::loadBackground(){ cur_bg=CCSprite::create("image/playbackground/bg1.png"); cur_bg->setPosition(ccp(winsize.width/2,winsize.height/2)); this->addChild(cur_bg,0); loadNextMap(); addCollisions(); }
//updata更新下一张背景图片,1/60秒调用一次 void MyPlayLayer::update(float dt) { contactBegein(); changeHard(); moveCollisions(); setScore(); cur_bg->setPositionX(cur_bg->getPositionX()-sprite->m_speed); next_bg->setPositionX(next_bg->getPositionX()-sprite->m_speed); if (next_bg->getPositionX()<=winsize.width/2) { cur_bg=next_bg; loadNextMap(); } }