void ParticleMainScene::createParticleSystem() { ParticleSystem *particleSystem = NULL; /* * Tests: * 1: Point Particle System using 32-bit textures (PNG) * 2: Point Particle System using 16-bit textures (PNG) * 3: Point Particle System using 8-bit textures (PNG) * 4: Point Particle System using 4-bit textures (PVRTC) * 5: Quad Particle System using 32-bit textures (PNG) * 6: Quad Particle System using 16-bit textures (PNG) * 7: Quad Particle System using 8-bit textures (PNG) * 8: Quad Particle System using 4-bit textures (PVRTC) */ removeChildByTag(kTagParticleSystem, true); // remove the "fire.png" from the TextureCache cache. Texture2D *texture = TextureCache::getInstance()->addImage("Images/fire.png"); TextureCache::getInstance()->removeTexture(texture); //TODO: if (subtestNumber <= 3) // { // particleSystem = new ParticleSystemPoint(); // } // else { particleSystem = new ParticleSystemQuad(); } switch( subtestNumber) { case 1: Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888); particleSystem->initWithTotalParticles(quantityParticles); particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); break; case 2: Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444); particleSystem->initWithTotalParticles(quantityParticles); particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); break; case 3: Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::A8); particleSystem->initWithTotalParticles(quantityParticles); particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); break; // case 4: // particleSystem->initWithTotalParticles(quantityParticles); // ////---- particleSystem.texture = [[TextureCache sharedTextureCache] addImage:@"fire.pvr"]; // particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); // break; case 4: Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888); particleSystem->initWithTotalParticles(quantityParticles); particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); break; case 5: Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444); particleSystem->initWithTotalParticles(quantityParticles); particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); break; case 6: Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::A8); particleSystem->initWithTotalParticles(quantityParticles); particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); break; // case 8: // particleSystem->initWithTotalParticles(quantityParticles); // ////---- particleSystem.texture = [[TextureCache sharedTextureCache] addImage:@"fire.pvr"]; // particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); // break; default: particleSystem = NULL; CCLOG("Shall not happen!"); break; } addChild(particleSystem, 0, kTagParticleSystem); particleSystem->release(); doTest(); // restore the default pixel format Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888); }
static mrb_value read_value(MarshalContext *ctx) { mrb_state *mrb = ctx->mrb; char type = ctx->readByte(); mrb_value value; if (mrb->arena_idx > maxArena) maxArena = mrb->arena_idx; int arena = mrb_gc_arena_save(mrb); switch (type) { case TYPE_NIL : value = mrb_nil_value(); break; case TYPE_TRUE : value = mrb_true_value(); break; case TYPE_FALSE : value = mrb_false_value(); break; case TYPE_FIXNUM : value = mrb_fixnum_value(read_fixnum(ctx)); break; case TYPE_BIGNUM : value = mrb_fixnum_value(read_bignum(ctx)); break; case TYPE_FLOAT : value = mrb_float_value(mrb, read_float(ctx)); ctx->objects.add(value); break; case TYPE_STRING : value = read_string_value(ctx); ctx->objects.add(value); break; case TYPE_ARRAY : value = read_array(ctx); break; case TYPE_HASH : value = read_hash(ctx); break; case TYPE_SYMBOL : value = mrb_symbol_value(read_symbol(ctx)); break; case TYPE_SYMLINK : value = mrb_symbol_value(read_symlink(ctx)); break; case TYPE_OBJECT : value = read_object(ctx); break; case TYPE_IVAR : value = read_instance_var(ctx); break; case TYPE_LINK : value = read_link(ctx); break; case TYPE_USERDEF : value = read_userdef(ctx); ctx->objects.add(value); break; default : CCLOG( "Marshal.load: unsupported value type '%c',gbufsize %d",type,g_buf_size); CCAssert(false,"f**k"); //exit(0); } mrb_gc_arena_restore(mrb, arena); return value; }
int App::run(void) { const char *QUICK_COCOS2DX_ROOT = getenv("QUICK_COCOS2DX_ROOT"); SimulatorConfig::sharedDefaults()->setQuickCocos2dxRootPath(QUICK_COCOS2DX_ROOT); loadProjectConfig(); HWND hwndConsole = NULL; if (m_project.isShowConsole()) { AllocConsole(); freopen("CONOUT$", "wt", stdout); freopen("CONOUT$", "wt", stderr); // disable close console hwndConsole = GetConsoleWindow(); if (hwndConsole != NULL) { HMENU hMenu = GetSystemMenu(hwndConsole, FALSE); if (hMenu != NULL) DeleteMenu(hMenu, SC_CLOSE, MF_BYCOMMAND); ShowWindow(hwndConsole, SW_SHOW); BringWindowToTop(hwndConsole); } } m_project.dump(); if (m_project.isWriteDebugLogToFile()) { const string debugLogFilePath = m_project.getDebugLogFilePath(); m_writeDebugLogFile = fopen(debugLogFilePath.c_str(), "w"); if (!m_writeDebugLogFile) { CCLOG("Cannot create debug log file %s", debugLogFilePath.c_str()); } } do { m_exit = TRUE; // create the application instance m_app = new AppDelegate(); m_app->setProjectConfig(m_project); // set environments SetCurrentDirectoryA(m_project.getProjectDir().c_str()); CCFileUtils::sharedFileUtils()->setSearchRootPath(m_project.getProjectDir().c_str()); CCFileUtils::sharedFileUtils()->setWritablePath(m_project.getWritableRealPath().c_str()); // create opengl view CCEGLView* eglView = CCEGLView::sharedOpenGLView(); eglView->setMenuResource(MAKEINTRESOURCE(IDC_LUAHOSTWIN32)); eglView->setWndProc(WindowProc); eglView->setFrameSize(m_project.getFrameSize().width, m_project.getFrameSize().height); eglView->setFrameZoomFactor(m_project.getFrameScale()); // make window actived m_hwnd = eglView->getHWnd(); BringWindowToTop(m_hwnd); SetWindowTextA(m_hwnd, "projectgame"); // restore window position const CCPoint windowOffset = m_project.getWindowOffset(); if (windowOffset.x != 0 || windowOffset.y != 0) { eglView->moveWindow(windowOffset.x, windowOffset.y); } // set icon HICON icon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_LUAHOSTWIN32)); SendMessage(m_hwnd, WM_SETICON, ICON_BIG, (LPARAM)icon); if (hwndConsole) { SendMessage(hwndConsole, WM_SETICON, ICON_BIG, (LPARAM)icon); } // update menu createViewMenu(); updateMenu(); // run game CCLuaStack *stack = CCLuaEngine::defaultEngine()->getLuaStack(); const vector<string> arr = m_project.getPackagePathArray(); for (vector<string>::const_iterator it = arr.begin(); it != arr.end(); ++it) { stack->addSearchPath(it->c_str()); } m_app->run(); // cleanup CCScriptEngineManager::sharedManager()->removeScriptEngine(); CCScriptEngineManager::purgeSharedManager(); CocosDenshion::SimpleAudioEngine::end(); delete m_app; m_app = NULL; } while (!m_exit); FreeConsole(); if (m_writeDebugLogFile) fclose(m_writeDebugLogFile); return 0; }
void ZFTimer::checkTimer() { CCLOG("I'm here!"); }
void ZFTimer::pauseTimer() { CCLOG("Pause Timer"); timerIsRunning = false; }
void TestDemo::onEnter() { CCLOG("onEnter"); this->setPosition(ccp(10, 290)); }
TestDemo::~TestDemo() { CCLOG("TestDemo de construct"); }
TestDemo::TestDemo() { CCLOG("TestDemo construct"); }
BattleController::~BattleController(void) { CCLOG("BattleController destroy"); CC_SAFE_RELEASE_NULL(m_battleWorld); }
void BattleController::loadSelfEntities() { BattleService* battleService=ServiceFactory::getInstance()->getPveBattleService(); std::vector<int> troops=battleService->getSelfTroops(); int teamSize=troops.size(); int entityId=0; for (int i=0; i<teamSize; ++i) { entityId=troops[i]; if (entityId) { CCLOG("entity id:%d",entityId); GameEntity* entity=createSelfTroopEntity(entityId,i); // //取得坐标 // convertCoord(i, &col, &row, &x, &y); // // //创建对象 // GameEntity* entity=EntityFactory::getInstance()->createBattlePlayer(entityId); // // addEntityToSelfTroops(entity, col, row); // // //临时的。set unit property。应该在EntityFactory创建的时候从配置文件中设置相应值。如果是玩家数据,则要做相应设置 // UnitProperty* unitProperty=entity->getUnitProperty(); // unitProperty->setDamage(10); // unitProperty->setDefence(10); // unitProperty->setHealth(100); // unitProperty->setMaxHealth(100); // // //set battle property // BattleProperty* battleProperty=entity->getBattleProperty(); // battleProperty->setCol(col); // battleProperty->setRow(row); // battleProperty->setSide(kSelfSide); // // //set animation // CCDictionary* data=new CCDictionary(); // data->setObject(CCString::create(CCGE_ANIMATION_IDLE), CCGE_ANIMATION_NAME); // data->setObject(CCInteger::create(kEightDirctionRightBottom), CCGE_ANIMATION_DIRECTION); // MessageManager::defaultManager()->dispatchMessage(MSG_CHANGE_ANIMATION, NULL, entity,data); // // RendererComponent* rendererComponent=static_cast<RendererComponent*>(entity->getComponent("RendererComponent")); // CCNode* renderer=rendererComponent->getRenderer(); // renderer->setScale(1.5f); // renderer->setZOrder(col); // // //设置坐标 // // //y方向居中对齐,坐标要加0.5 // CCPoint pos=dimetric::StaticTopViewCoordinateFormulae::gameToView2F(x,y+0.5); // pos.x+=kBattleSelfOffsetX+x*kBattleCellOffsetX; // pos.y+=kBattleSelfOffsetY+y*kBattleCellOffsetY; // renderer->setPosition(pos); // // m_view->addChild(renderer); // // // //血条 // HealthBarComponent* healthBarComponent=entity->getHealthBarComponent(); // healthBarComponent->setMaxHp(unitProperty->getMaxHealth()); // healthBarComponent->setCurrentHp(unitProperty->getHealth()); // // healthBarComponent->getHealthBar()->setPosition(ccp(0,85)); registerEntityMessage(entity); } } }