bool GameLayer::init(){ if ( !LayerColor::initWithColor(Color4B(255, 255, 255, 255)) ) { return false; } visibleSize = Director::getInstance()->getVisibleSize(); gun = Gun::create(); gun->setScale(0.25); gun->setPosition(Vec2(120,visibleSize.height/2-180)); addChild(gun,1); touchTest(); //触摸检测 this->schedule(schedule_selector(GameLayer::checkCollision), 0.1);//启动检测碰撞的函数 //////////////////////////// //文件解析 str="Data.xml"; // xmller.giveBirthTo(str); xmller.createwithxmlfile(str); //更换背景 std::string a= xmller.getLevel01(); int i = atoi(a.c_str()); log("哇擦了%d",i); auto levelNumber = __String::createWithFormat("bg%d.png",i); log("%s",levelNumber->getCString()); auto bg = Sprite::create(levelNumber->getCString()); bg->setPosition(visibleSize/2); auto fade1 = FadeTo::create(2.0, 150); auto fade2 = FadeIn::create(2.0); auto seq = RepeatForever::create( Sequence::create(fade1,fade2,NULL)); bg->runAction(seq); addChild(bg); loadLayer(); //加载场景 addSprite(); //添加界面UI元素 //拿到子弹数量,给全局变量 auto bulletnm = xmller.getLevel03(); int b = atoi(bulletnm.c_str()); bulletNumber = b; butemp =0; return true; }
int runTests() { int passed = 1; char newchar; passed &= lsTest(); printf("\nEnter a char to continue!\n"); scanf(" %c", &newchar); passed &= test_cat(); printf("\nEnter a char to continue!\n"); scanf(" %c", &newchar); passed &= test_read(); printf("\nEnter a char to continue!\n"); scanf(" %c", &newchar); passed &= test_write(); printf("\nEnter a char to continue!\n"); scanf(" %c", &newchar); passed &= cdTest(); printf("\nEnter a char to continue!\n"); scanf(" %c", &newchar); passed &= chmodTest(); printf("\nEnter a char to continue!\n"); scanf(" %c", &newchar); passed &= mkdirTest(); printf("\nEnter a char to continue!\n"); scanf(" %c", &newchar); passed &= touchTest(); printf("\nEnter a char to continue!\n"); scanf(" %c", &newchar); passed &= linkTest(); printf("\nEnter a char to continue!\n"); scanf(" %c", &newchar); passed &= rmdirTest(); printf("\nEnter a char to continue!\n"); scanf(" %c", &newchar); passed &= pwdTest(); printf("\nEnter a char to continue!\n"); scanf(" %c", &newchar); passed &= cpTest(); printf("\nEnter a char to continue!\n"); scanf(" %c", &newchar); passed &= mvTest(); printf("\nEnter a char to continue!\n"); scanf(" %c", &newchar); passed &= lseekTest(); if (passed == 1) { printf("\n\nEVERYTHING PASSED\n\n"); } else { printf("\n\nNOT EVERYTHING PASSED\n\n"); } }