当前位置: 首页>>代码示例>>C++>>正文


C++ BackgroundLayer::addElement方法代码示例

本文整理汇总了C++中BackgroundLayer::addElement方法的典型用法代码示例。如果您正苦于以下问题:C++ BackgroundLayer::addElement方法的具体用法?C++ BackgroundLayer::addElement怎么用?C++ BackgroundLayer::addElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BackgroundLayer的用法示例。


在下文中一共展示了BackgroundLayer::addElement方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: init


//.........这里部分代码省略.........
    unsigned int rmask = 0x000000ff;
    unsigned int gmask = 0x0000ff00;
    unsigned int bmask = 0x00ff0000;
    unsigned int amask = 0xff000000;
#endif
	this->textSurface = SDL_CreateRGBSurface( 0, Renderer::screenWidth, Renderer::screenHeight, 32, rmask, gmask, bmask, amask);

	OGLRenderableFactory factory = OGLRenderableFactory();

	this->game = GameFactory::loadGame("game.xml");
	this->game->loadCurrentLevel(&factory);
	bExit = false;

	
	soundManager = new SoundManager();
	soundManager->init();
	
	//soundManager->loadMusic("A991Project.ogg");
	//soundManager->playCurrentMusic();
	
	//soundManager->loadExplosionSound("Grenade-SoundBible.com-1777900486.wav");
	


	particleManager = new ParticleManager();
	/*
    drawthread = SDL_CreateThread(thread_func, this);
    if ( drawthread == NULL ) {
        fprintf(stderr, "Unable to create draw thread: %s\n", SDL_GetError());
        exit(0);
    }
	*/
	this->game->setOnDestroyCallback(onDestroyCallback,this);
	this->game->setOnHitCallback(onHitCallback,this);

	this->fbAccumulation = NULL;
	this->fbDrawing = NULL;
	this->fbHalfRes1 = NULL;
	this->fbHalfRes2 = NULL;

	shaderTexturing = new Shader();
	shaderTexturing->load_fragment("fragment_texturing.gl");
	shaderTexturing->load_vertex("test.gl");

	shaderDistort = new Shader();
	shaderDistort->load_fragment("fragment_distort.gl");
	shaderDistort->load_vertex("test.gl");

	shaderGaussianBlurVertical = new Shader();
	shaderGaussianBlurVertical->load_fragment("fragment_gaussian_vertical.gl");
	shaderGaussianBlurVertical->load_vertex("test02.gl");

	shaderGaussianBlurHorizontal = new Shader();
	shaderGaussianBlurHorizontal->load_fragment("fragment_gaussian_horizontal.gl");
	shaderGaussianBlurHorizontal->load_vertex("test02.gl");


	Texture * texture = new Texture(2,2,(unsigned char*)g_texdata);

	unsigned int * pixels = (unsigned int *)malloc(sizeof(unsigned int)*30*30);
	TextureGenerator::generateTriangle(10,4,pixels,30,0xffffffff);

	this->spriteAccumulation = new Sprite(texture,100.f,100.f,0,0,1,1);
	this->spriteBullet = new Sprite(texture,5.f,5.f,1,1,0,0);
	this->spriteDrawing = new Sprite(texture,100.f,100.f,0,0,1,1);
	this->spriteDummy = new Sprite(texture,100.f,100.f,0,0,1,1);
	this->spriteCovering = new Sprite(texture,Renderer::screenWidth,Renderer::screenHeight,0,0,1,1);
	this->spriteRectangle = new Sprite(texture,10.f,1.f,0,0,1,1);


	unsigned int * pixels2 = (unsigned int *)malloc(sizeof(unsigned int)*30*30);
	TextureGenerator::generateCircle(0,0,pixels2,30,0xffffffff);
	this->spriteCircle = new Sprite(new Texture(30,30,(unsigned char*)pixels2),10.f,10.f,1,1,0,0);
	//this->spriteCircle = this->spriteBullet;

	Texture * textSurfaceTexture = new Texture(Renderer::screenWidth,Renderer::screenHeight,(unsigned char*)this->textSurface->pixels);
	this->spriteTextSurface = new Sprite(textSurfaceTexture,Renderer::screenWidth,Renderer::screenHeight,0,1,1,0);

	this->spriteShip = new Sprite(new Texture(30,30,(unsigned char*)pixels),30.f,30.f,1,1,0,0);

	unsigned int * pixelsgrid = (unsigned int*)malloc(sizeof(unsigned int)* 100 * 100);
	TextureGenerator::generateGrid(pixelsgrid,100,100,20,0xff0909aa);
	this->spriteGrid = new Sprite(new Texture(100,100,(unsigned char*)pixelsgrid),100.f,100.f,0,0,1,1);
	BackgroundLayer * backgroundLayer = new BackgroundLayer(Renderer::screenWidth,Renderer::screenHeight);
	backgroundLayer->addElement(this->spriteGrid,100,100);
	this->backgroundManager.addLayer(backgroundLayer);
	
	unsigned int * pixelsStarfield = (unsigned int*)calloc(sizeof(unsigned int), 100 * 100);
	TextureGenerator::generateStarfield(pixelsStarfield,100,100,10);
	backgroundLayer = new BackgroundLayer(Renderer::screenWidth,Renderer::screenHeight,0.0,-1.5f);
	backgroundLayer->addElement(new Sprite(new Texture(100,100,(unsigned char*)pixelsStarfield),100.f,100.f,0,0,1,1),100,100);
	this->backgroundManager.addLayer(backgroundLayer);

	unsigned int * pixelsStarfield2 = (unsigned int*)calloc(sizeof(unsigned int), 100 * 100);
	TextureGenerator::generateStarfield(pixelsStarfield2,100,100,10);
	backgroundLayer = new BackgroundLayer(Renderer::screenWidth,Renderer::screenHeight,0.0,-1.0f);
	backgroundLayer->addElement(new Sprite(new Texture(100,100,(unsigned char*)pixelsStarfield2),100.f,100.f,0,0,1,1),100,100);
	this->backgroundManager.addLayer(backgroundLayer);
	
}
开发者ID:,项目名称:,代码行数:101,代码来源:


注:本文中的BackgroundLayer::addElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。