/** * 初期状態の処理 */ void ScenarioTracer::execInitial() { initAction(); // entry アクション(INITIAL) mState = WALKING; // 状態遷移 modeChangeAction(); // entry アクション(WALKING) }
BaseFilter::BaseFilter(FilterDescription desc, ccPluginInterface * parent_plugin) : m_action(0) , m_desc(desc) , m_show_progress(true) { initAction(); m_parent_plugin = parent_plugin; }
CPrivateInfo::CPrivateInfo(CConnect *link, IMakeXml *xml, UserInformation myself, QWidget *parent) : QDialog(parent), m_link(link), m_MXml(xml), m_userinfo(myself), ui(new Ui::CPrivateInfo) { ui->setupUi(this); initWnd(); initWidget(); initAction(); }
CTalkDlg::CTalkDlg(CConnect *link, IMakeXml *xml, FriendInformation frd,QWidget *parent) :QDialog(parent), ui(new Ui::CTalkDlg), m_link(link), m_MXml(xml), m_frd(frd) { ui->setupUi(this); initWnd(); initWidget(); initAction(); }
StartSprite* StartSprite::create(int row, int col) { auto star = new StartSprite(); auto filename = star->getStarFilename(); if (star && star->initWithFile(filename)) { star->setData(filename.substr(0,4), row, col); star->autorelease(); star->initAction(row, col); return star; } CC_SAFE_DELETE(star); return nullptr; }
TitleWidget::TitleWidget(const bool &isMainTitle, QWidget *parent) : BasedStyleShetWidget(parent) { setAttribute(Qt::WA_TranslucentBackground); setObjectName("NetNaseTitle"); initUi(isMainTitle); if (isMainTitle) { setFixedSize(mainTitleSize); initAction(); } else setFixedSize(logInTitleSize); }
bool CPrivateInfo::eventFilter(QObject *watched, QEvent *event) { if( watched == this ) { //窗口停用,变为不活动的窗口 if(QEvent::WindowDeactivate == event->type()) { qDebug() << "deactive status " << endl; disAction(); return true ; } else { initAction(); return false ; } } return false ; }
bool UserManagement_Invoicing::init(MainWindow *parent) { PluginInterface *plugin = parent->getPlugin("UserManagementIF"); userManagementInterface = dynamic_cast<UserManagementInterface *>(plugin); if(!userManagementInterface) { return false; } else { userManagementInterface->registeObserver(this); } initAction(); initToolBar(); if(!showLoginWindow()) { exit(0); } userManagement(); userChanged(); this->parent = parent; return true; }
// on "init" you need to initialize your instance bool GameScene::init() { if ( !Layer::init() ) { return false; } Size visibleSize = Director::getInstance()->getVisibleSize(); Point origin = Director::getInstance()->getVisibleOrigin(); auto bg = Sprite::create("GameBackground.png"); bg->setPosition(Point(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y)); this->addChild(bg, -1); SpriteFrameCache::getInstance()->addSpriteFramesWithFile("GameSceneSprite.plist","GameSceneSprite.png"); playerSprite = Sprite::createWithSpriteFrameName("planeBlue1.png"); playerSprite->setPosition(Point(visibleSize.width * 0.2 + origin.x, visibleSize.height/2 + origin.y)); this->addChild(playerSprite); // Test function initAction(); initAnimation(); return true; }
BaseFilter::BaseFilter(FilterDescription desc) : m_action(0) , m_desc(desc) { initAction(); }
// on "init" you need to initialize your instance bool Start::init() { mScreenSize = CCDirector::sharedDirector()->getWinSize(); for (int i = 0; i<gbackgroundNum; i++) { CCSprite *pbackGround = CCSprite::create("daybackground.png"); CCRect rcBounding = pbackGround->boundingBox(); pbackGround->setPosition(ccp(rcBounding.size.width*(i*2+1) / 2, mScreenSize.height / 2)); this->addChild(pbackGround); } CCSize groundSize; for (int i = 0; i<ggroundNum; i++) { pGround[i] = CCSprite::create("ground.png"); groundSize = pGround[i]->getContentSize(); pGround[i]->setPosition(ccp(groundSize.width*(i*2+1) / 2, groundSize.height / 2)); this->addChild(pGround[i],1); } mbirdstr.push_back("birdblue"); mbirdstr.push_back("birdred"); mbirdstr.push_back("birdyellow"); mbirdclolor=rand()%100%3; string strplist=mbirdstr[mbirdclolor]+".png"; tbBird = CCSprite::create(strplist.c_str()); tbBird->setPosition(ccp(mScreenSize.width/2,mScreenSize.height/2+10.)); addChild(tbBird,0); initAction(); CCMenuItemImage *tbstart = CCMenuItemImage::create("start.png", "start.png", this, menu_selector(Start::tbstartCallback) ); tbstart->setPosition(ccp(mScreenSize.width/4,groundSize.height + 10 + tbstart->getContentSize().height/2)); CCMenu* pMenu1 =CCMenu::create(tbstart, NULL); pMenu1->setPosition( CCPointZero ); addChild(pMenu1); CCMenuItemImage *tbscore = CCMenuItemImage::create("top.png", "top.png", this, menu_selector(Start::tbtopCallback) ); tbscore->setPosition(ccp(mScreenSize.width*3/4,groundSize.height+10 + tbscore->getContentSize().height/2)); CCMenu* pMenu2 =CCMenu::create(tbscore, NULL); pMenu2->setPosition( CCPointZero ); addChild(pMenu2); CCSprite *m_pFlappyBird = CCSprite::create("flappybird.png"); //CCSprite *m_pFlappyBird = CCSprite::create("sprites.png",CCRectMake(0,680,180,55)); CCRect rcBounding = m_pFlappyBird->boundingBox(); float fFlappyBirdHeight=rcBounding.size.height/2.0f; float xpos=mScreenSize.width/2; float ypos=mScreenSize.height*3/4+20; m_pFlappyBird->setPosition(ccp(xpos, ypos)); // 设置在屏幕中间 this->addChild(m_pFlappyBird); CCSprite*m_pRate = CCSprite::create("rate.png"); rcBounding = m_pRate->boundingBox(); CCSize startSize = m_pRate->getContentSize(); float fRateWidth=rcBounding.size.width/2.0f; float fRateHeight=rcBounding.size.height/2.0f; xpos=mScreenSize.width/2.0f; ypos=tbscore->boundingBox().getMaxY()+fRateHeight+10; m_pRate->setPosition(ccp(xpos, ypos)); // 设置在屏幕中间 this->addChild(m_pRate); scheduleUpdate(); //CCActionInterval* actionTo = CCMoveBy::create(0.5, ccp(0, 10)); //CCActionInterval* actionByBack = actionTo->reverse(); //tbBird->runAction(CCRepeatForever::create(CCSequence::create( actionTo,actionByBack,NULL))); return true; }
int main(int argc, char* argv[]) { // Init initPath(argv[0]); SDL_Surface* screen = NULL; SDL_Event event; int *seed; srand((int)seed); int previousTime = 0, currentTime = 0; Events *flags = createEventFlags(); SDL_Init(SDL_INIT_VIDEO); SDL_SetEventFilter(eventFilter); screen = SDL_SetVideoMode(800, 600, 32, SDL_HWSURFACE | SDL_ASYNCBLIT | SDL_DOUBLEBUF | SDL_NOFRAME); SDL_WM_SetCaption("Tower Defense", NULL); Action *actionList = initAction(); Map* map = createMap(getPath("resources/Forest.png")); _map = map; SDL_Rect surface = {0, 0, 720, 600}; Viewport* viewport = createViewport(screen, surface, map); _viewport = viewport; // FIXME uh? what's this thing? surface.x = 800 - 80; surface.y = 0; surface.h = 80; surface.w = 600; // Creation of the enemies TypeEn *whiteCat = createTypeEn(100, 5, false, true, true, false, 1,getPath("resources/white_transparent_cat.png")); TypeEn *blackCat = createTypeEn(100, 5, false, true, true, false, 1,getPath("resources/black_transparent_cat.png")); Enemy *cat1 = createEnemy(1,1,whiteCat); Enemy *cat2 = createEnemy(1,10,whiteCat); Enemy *cat3 = createEnemy(5,5,blackCat); Enemy *cat4 = createEnemy(21,4,blackCat); TypeEn *zombie = createTypeEn(100,5,false,true,true,false,1,getPath("resources/zombie.png")); Enemy *zombie1 = createEnemy(4,4,zombie); Enemy *zombie2 = createEnemy(9,4,zombie); Enemy *zombie3 = createEnemy(9,9,zombie); Enemy *zombie4 = createEnemy(7,14,zombie); //Add enemy in the List List *catList = newList(cat4); pushList((void*)catList,cat2); pushList((void*)catList,cat3); // pushList((void*)catList,cat1); List *zombieList = newList(zombie1); /* pushList((void*)zombieList,zombie2);*/ /* pushList((void*)zombieList,zombie3);*/ /* pushList((void*)zombieList,zombie4);*/ // removeEnemyFromList(cat4,catList); //TOWER TypeBul *bullet = createTypeBul(getPath("resources/bullet.png"), 1); TypeTo *tower = createTypeTo(0,5,0,0,false,false,false,false,bullet,NULL,getPath("resources/tower.png")); upgradeTypeTo(tower,0.5,getPath("resources/towerUP.png")); flags->selectedTower = tower->nextType; Tower *tower1 = createTower(7,7,tower); List *towerList = newList(tower1); flags->towerList = towerList; // Create and Renders the right panel game menu SDL_Rect surfaceMenu = {720, 0, 800, 600}; Menu* menu = menu_create(screen, surfaceMenu); menu_loadBackground(menu, "resources/enemyFont.gif"); // For testing only, we add a few random buttons menu_addButton(menu, button_createBuildButton(tower)); menu_addButton(menu, button_createBuildButton(tower)); menu_addButton(menu, button_createBuildButton(tower)); menu_render(menu); _cell = *getCase(20,11); // Main loop while(actionList[QUIT].boolean == NULL) { // Managing the events manageEvents(viewport, flags,actionList); for(int i=1; i<ACTION_LENGTH; i++) { if(actionList[i].boolean) { int repeat = (*actionList[i].action)(viewport,flags,actionList[i].boolean); if(!repeat) { actionList[i].boolean = NULL; } } } // Redraws the map (viewport contents) before blitting stuff on it updateViewport(viewport); ///////////////////////////// DEBUG WALL ///////////////////////////// SDL_Rect position; for(int i=0; i < _map->nbCaseW; i++) { for(int j=0; j < _map->nbCaseH; j++) { Case cell = *getCase(i,j); position.x = cell.x; position.y = cell.y; if(map->matrice[i][j].hasTower == 2) { SDL_Surface *wall = IMG_Load(getPath("resources/brick.png")); blitToViewport(viewport, wall, NULL, &position); } } } position.x = _cell.x; position.y = _cell.y; blitToViewport(viewport, IMG_Load(getPath("resources/candy_cane.png")), NULL, &position); ///////////////////////////////////////////////////////////////////// // Move enemies if(flags->enemy_Path_Calculation) { pathReCalculation(catList); pathReCalculation(zombieList); flags->enemy_Path_Calculation = false; } moveEnemyList(zombieList); moveEnemyList(catList); // Blit enemies drawEnemyList(zombieList); drawEnemyList(catList); //Blit TOWER /* if(event.key.keysym.sym == SDLK_u){*/ /* upgrade(tower1);*/ /* }*/ Bullet *bullet1 = createBullet(tower1); animateBullet(bullet1); drawTowerList(towerList); /* This should be handled by event.c switch(event.key.keysym.sym){ case SDLK_a: flags->selectedTower = tower; break; case SDLK_b: flags->selectedTower = tower->nextType; break; default: break; }*/ /* */ // Ask SDL to swap framebuffers to update the displayed screen SDL_Flip(screen); // Managing frames currentTime = SDL_GetTicks(); if (currentTime - previousTime <= 20) { SDL_Delay(20 - (currentTime - previousTime)); } // DEBUG printf("Frame %i : %ims\n", framecounter++, currentTime - previousTime); previousTime = SDL_GetTicks(); } free(actionList); SDL_Quit(); return EXIT_SUCCESS; }
// on "init" you need to initialize your instance bool HelloWorld::init() { ////////////////////////////// // 1. super init first if ( !CCLayer::init() ) { return false; } mbirdstr.push_back("birdblue"); mbirdstr.push_back("birdred"); mbirdstr.push_back("birdyellow"); mbirdclolor=rand()%100%3; // EFFECT_PLAY(true,MUSIC_SWOOSHING); //播放背景音乐 // CocosDenshion::SimpleAudioEngine::sharedEngine()->playBackgroundMusic(MUSIC_JUMP, true); //////////////////////////////////////////////////// // 下面添加创建自己的Sprite的代码 //////////////////////////////////////////////////// mScreenSize = CCDirector::sharedDirector()->getWinSize(); mFPS=CCDirector::sharedDirector()->getAnimationInterval(); mfac=CCDirector::sharedDirector()->getContentScaleFactor(); mfax = 320.f/mScreenSize.width; //gBardis = 5.f*gUpVelocity/mfac; gBardis = mScreenSize.height*2.f/9.0f-5; //m_addbartime=mScreenSize.width*mFPS*mfax*1.f/2.f/MOVESPEED-10; //m_addbartime=3; initWorld(); for (int i = 0; i<GBACKGROUNDNUM; i++) { addBackGround(i); } int imaxgroundnum=1; for (int i = 0; i<imaxgroundnum; i++) { imaxgroundnum=addGround(i); } m_ilastground=imaxgroundnum-1; CCLOG("m_pLastGround->boundingBox() first x:%f,:%f ", (m_pGroundVec[m_ilastground])->boundingBox().getMaxX(), (m_pGroundVec[m_ilastground])->boundingBox().size.width); addStart(); addTop(); //addRate(); //addFlappyBird(); addBird(); addScore(); addGameOver(); m_pScore->setVisible(false); m_pGameOver->setVisible(false); this->goReady(); addBarContainer(); setTouchEnabled(true); myflag=0; m_istatus=GETREADY; m_bhitbar=false; //scheduleOnce(schedule_selector(HelloWorld::startGame), 1); this->scheduleUpdate(); //创建动画 initAction(); myangle=0.f; return true; }